From 910fde75e1ec62914aa9dbee97af6cd584095c85 Mon Sep 17 00:00:00 2001 From: zipg Date: Wed, 1 Jul 2026 00:00:26 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=B7=A6?= =?UTF-8?q?=E4=BE=A7=E8=BF=90=E8=A1=8C=E5=A4=9A=E6=9D=A1=20SQL=20=E5=8F=AA?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E9=A6=96=E6=9D=A1=20(#2256)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: staff --- apps/desktop/src/components/editor/QueryEditor.vue | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue index 758d62893..f756dc020 100644 --- a/apps/desktop/src/components/editor/QueryEditor.vue +++ b/apps/desktop/src/components/editor/QueryEditor.vue @@ -335,15 +335,20 @@ function handleTab(view: EditorViewType): boolean { return true; } -function requestExecute(options: { forceCurrent?: boolean } = {}) { +interface RequestExecuteOptions { + forceCurrent?: boolean; + ignoreSelection?: boolean; +} + +function requestExecute(options: RequestExecuteOptions = {}) { const currentView = view.value; if (!currentView) return false; return requestExecuteFromView(currentView, currentView.state.selection.main.head, options); } -function requestExecuteFromView(currentView: EditorViewType, cursorPos: number, options: { forceCurrent?: boolean } = {}) { +function requestExecuteFromView(currentView: EditorViewType, cursorPos: number, options: RequestExecuteOptions = {}) { const selection = currentView.state.selection.main; - if (!selection.empty) { + if (!options.ignoreSelection && !selection.empty) { // Has manual selection → execute directly, skip picker. emit("execute", sqlExecutionSnapshotFromView(currentView)); return true; @@ -524,7 +529,7 @@ function executeSqlStatementFromGutter(currentView: EditorViewType, line: { from if (!statementRange) return false; event.preventDefault(); event.stopPropagation(); - emit("execute", statementRange.sql); + requestExecuteFromView(currentView, line.from, { ignoreSelection: true }); currentView.focus(); return true; }