From 025b465bf1789b6104c373fa4048e043b65c8431 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Thu, 28 May 2026 21:35:23 +0800 Subject: [PATCH] fix(editor): preserve scroll position after SQL execution After DDL/DML execution via the danger confirmation dialog, the editor scrolls to the top, making it hard to locate the executed statement. Fix by scrolling the cursor back into view after execution completes, using nextTick + requestAnimationFrame to wait for Splitpanes layout stabilization. --- .../desktop/src/components/editor/QueryEditor.vue | 10 +++++++++- .../desktop/src/components/layout/ContentArea.vue | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue index bfe5e24230..847f667756 100644 --- a/apps/desktop/src/components/editor/QueryEditor.vue +++ b/apps/desktop/src/components/editor/QueryEditor.vue @@ -1469,7 +1469,15 @@ function openReplace(): boolean { return searchPanelRef.value?.openReplace() ?? false; } -defineExpose({ openSearch, openReplace }); +function scrollCursorIntoView() { + if (!view.value || !editorViewModule) return; + const pos = view.value.state.selection.main.head; + view.value.dispatch({ + effects: editorViewModule.EditorView.scrollIntoView(pos, { y: "nearest" }), + }); +} + +defineExpose({ openSearch, openReplace, scrollCursorIntoView });