diff --git a/apps/desktop/src/components/layout/SqlEditorWorkspace.vue b/apps/desktop/src/components/layout/SqlEditorWorkspace.vue index 66c3bf467e..296907ad80 100644 --- a/apps/desktop/src/components/layout/SqlEditorWorkspace.vue +++ b/apps/desktop/src/components/layout/SqlEditorWorkspace.vue @@ -119,9 +119,9 @@ const storedResultPaneSize = Number(safeLocalStorageGet(SHARED_RESULT_PANE_STORA const resultPaneSize = ref(Number.isFinite(storedResultPaneSize) && storedResultPaneSize >= SHARED_RESULT_PANE_MIN_SIZE && storedResultPaneSize <= SHARED_RESULT_PANE_MAX_SIZE ? storedResultPaneSize : SHARED_RESULT_PANE_DEFAULT_SIZE); const showResultPane = ref(true); // The result pane stays mounted and animates its size between the stored -// split and 0, so collapsing/expanding glides instead of jumping: the stock -// splitpanes pane transition is re-enabled for this workspace in -// sqlEditorWorkspace.css (globals.css kills it for horizontal splitpanes). +// split and 0, so collapsing/expanding glides instead of jumping: the pane +// transition for this outer split is re-enabled in sqlEditorWorkspace.css +// (globals.css kills it for horizontal splitpanes). const resultPaneTargetSize = computed(() => (showSharedResult.value && showResultPane.value ? resultPaneSize.value : 0)); const editorPaneSize = computed(() => 100 - resultPaneTargetSize.value); // Entrance choreography is hydration-gated: groups present at first render diff --git a/apps/desktop/src/components/layout/sqlEditorWorkspace.css b/apps/desktop/src/components/layout/sqlEditorWorkspace.css index f702e6a31e..3c3a4283b4 100644 --- a/apps/desktop/src/components/layout/sqlEditorWorkspace.css +++ b/apps/desktop/src/components/layout/sqlEditorWorkspace.css @@ -17,12 +17,14 @@ --sql-workspace-ease-out: cubic-bezier(0.25, 1, 0.5, 1); } -/* Pane size transitions: restore splitpanes' stock behavior inside the - workspace (globals.css disables it for all horizontal splitpanes). */ -.sql-editor-workspace .splitpanes--ready .splitpanes__pane { +/* Pane size transitions: only the outer editor/result split animates pane + sizes (the result-pane collapse/expand glide). Group panes never animate + their sizes — splits use the entrance keyframes below — so they stay on + stock splitpanes behavior (transition, disabled while dragging). */ +.sql-editor-workspace .sql-editor-workspace-split.splitpanes--ready > .splitpanes__pane { transition: width 0.2s ease-out, height 0.2s ease-out !important; } -.sql-editor-workspace .splitpanes--ready.splitpanes--dragging .splitpanes__pane { +.sql-editor-workspace .sql-editor-workspace-split.splitpanes--ready.splitpanes--dragging > .splitpanes__pane { transition: none !important; } @@ -81,7 +83,7 @@ .sql-editor-workspace .result-surface-leave-active { transition: none; } - .sql-editor-workspace .splitpanes--ready .splitpanes__pane { + .sql-editor-workspace .sql-editor-workspace-split.splitpanes--ready > .splitpanes__pane { transition: none !important; } } diff --git a/apps/desktop/src/lib/__tests__/editor/queryEditorLineNumbers.spec.ts b/apps/desktop/src/lib/__tests__/editor/queryEditorLineNumbers.spec.ts new file mode 100644 index 0000000000..d5b69af0d0 --- /dev/null +++ b/apps/desktop/src/lib/__tests__/editor/queryEditorLineNumbers.spec.ts @@ -0,0 +1,68 @@ +import { describe, expect, it, vi } from "vitest"; +import { createQueryEditorLineNumberAlignmentExtension } from "@/lib/editor/queryEditorLineNumbers"; + +type MeasureSpec = { + read: (view: unknown) => unknown; + write: (data: unknown) => void; +}; + +function createPluginClass() { + let captured: unknown; + const FakeViewPlugin = { + fromClass(cls: unknown) { + captured = cls; + return cls; + }, + }; + createQueryEditorLineNumberAlignmentExtension(FakeViewPlugin as unknown as typeof import("@codemirror/view").ViewPlugin); + return captured as unknown as new (view: FakeView) => { + update: (update: { docChanged?: boolean; geometryChanged?: boolean; viewportChanged?: boolean; view: FakeView }) => void; + docViewUpdate: (view: FakeView) => void; + }; +} + +class FakeView { + lineWrapping: boolean; + requestMeasure = vi.fn((spec: MeasureSpec) => { + spec.write(spec.read(this)); + }); + defaultLineHeight = 20; + dom = { + querySelectorAll: () => [] as HTMLElement[], + }; + + constructor(lineWrapping: boolean) { + this.lineWrapping = lineWrapping; + } +} + +describe("query editor line number alignment extension", () => { + it("skips gutter measurement while line wrapping is off and clears once on transitions", () => { + const PluginClass = createPluginClass(); + const view = new FakeView(false); + const plugin = new PluginClass(view); + + // Constructor runs one pass because the initial state assumes wrapping + // until proven otherwise; that pass clears any stale inline alignment. + expect(view.requestMeasure).toHaveBeenCalledTimes(1); + + // Steady state without wrapping: geometry changes (every drag frame) + // must not schedule further gutter reads. + plugin.update({ geometryChanged: true, view }); + plugin.update({ docChanged: true, view }); + plugin.docViewUpdate(view); + expect(view.requestMeasure).toHaveBeenCalledTimes(1); + + // Enabling wrapping resumes measurement. + view.lineWrapping = true; + plugin.update({ geometryChanged: true, view }); + expect(view.requestMeasure).toHaveBeenCalledTimes(2); + + // Disabling wrapping runs exactly one clearing pass, then stops again. + view.lineWrapping = false; + plugin.update({ geometryChanged: true, view }); + expect(view.requestMeasure).toHaveBeenCalledTimes(3); + plugin.update({ viewportChanged: true, view }); + expect(view.requestMeasure).toHaveBeenCalledTimes(3); + }); +}); diff --git a/apps/desktop/src/lib/editor/queryEditorLineNumbers.ts b/apps/desktop/src/lib/editor/queryEditorLineNumbers.ts index 5b6f810b80..cdeaf8c038 100644 --- a/apps/desktop/src/lib/editor/queryEditorLineNumbers.ts +++ b/apps/desktop/src/lib/editor/queryEditorLineNumbers.ts @@ -23,6 +23,13 @@ export function createQueryEditorLineNumberAlignmentExtension(ViewPlugin: typeof return ViewPlugin.fromClass( class { private measureScheduled = false; + // Alignment is only ever needed for wrapped lines. While wrapping is + // off, every geometry change (each frame of a splitter drag resizing + // the editor, font changes, viewport moves) would otherwise re-read + // every gutter element for nothing. A single pass still runs on wrap + // transitions so stale inline alignment is cleared from live gutter + // elements. + private lastWrapping = true; constructor(view: import("@codemirror/view").EditorView) { this.scheduleMeasure(view); @@ -38,6 +45,9 @@ export function createQueryEditorLineNumberAlignmentExtension(ViewPlugin: typeof private scheduleMeasure(view: import("@codemirror/view").EditorView) { if (this.measureScheduled) return; + const wrapping = view.lineWrapping; + if (wrapping === this.lastWrapping && !wrapping) return; + this.lastWrapping = wrapping; this.measureScheduled = true; view.requestMeasure({ read: (measuredView) => { diff --git a/apps/desktop/src/styles/globals.css b/apps/desktop/src/styles/globals.css index 9305e0bb10..addedb324b 100644 --- a/apps/desktop/src/styles/globals.css +++ b/apps/desktop/src/styles/globals.css @@ -2437,6 +2437,14 @@ html.dbx-legacy-webview [data-slot="dialog-content"][class*="sm:max-w-[min(1180p .splitpanes--horizontal .splitpanes__pane { transition: none !important; } +/* Stock splitpanes keeps `will-change: width/height` on ready panes forever. + Layout properties are never composited, so the hint cannot pay off; it only + keeps every pane (and the editor/grid subtree inside it) in a pessimized + style/layout state, which amplifies per-frame work while dragging a + splitter. Killing it app-wide keeps the stock pane transition intact. */ +.splitpanes--ready .splitpanes__pane { + will-change: auto !important; +} .splitpanes--vertical > .splitpanes__splitter { width: 3px !important; border-left: 1px solid var(--border);