From 97f5a37ba8d07943d1b1e5a3f61bf68f8f7232e5 Mon Sep 17 00:00:00 2001 From: zipg Date: Fri, 4 Sep 2026 09:49:54 +0800 Subject: [PATCH] fix(editor): keep shift-click selection in query editor --- apps/desktop/src/components/editor/QueryEditor.vue | 5 +++++ .../editor/__tests__/QueryEditorContextMenu.spec.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue index 46a6f24512..001771fe0d 100644 --- a/apps/desktop/src/components/editor/QueryEditor.vue +++ b/apps/desktop/src/components/editor/QueryEditor.vue @@ -1337,6 +1337,11 @@ function updateEditorSelectionDropCursor(currentView: EditorViewType, event: Mou } function startEditorSelectionDrag(currentView: EditorViewType, event: MouseEvent): boolean { + // Shift is CodeMirror's native extend-selection gesture. Keep it out of the + // custom selection drag path so a shift-click inside the current selection + // extends or shrinks the selection instead of collapsing it to the cursor. + if (event.shiftKey) return false; + const selection = selectedRangeAtPointer(currentView, event); if (!selection) return false; diff --git a/apps/desktop/src/components/editor/__tests__/QueryEditorContextMenu.spec.ts b/apps/desktop/src/components/editor/__tests__/QueryEditorContextMenu.spec.ts index 9419dd2987..14aafffc45 100644 --- a/apps/desktop/src/components/editor/__tests__/QueryEditorContextMenu.spec.ts +++ b/apps/desktop/src/components/editor/__tests__/QueryEditorContextMenu.spec.ts @@ -165,3 +165,16 @@ describe("QueryEditor batch column selection", () => { expect(source).toContain("maxRenderedOptions: batchColumnSelectionExpandedRendering ? Number.MAX_SAFE_INTEGER : 100,"); }); }); + +describe("QueryEditor pointer selection", () => { + it("lets CodeMirror handle shift-click instead of starting the selection drag gesture", () => { + const start = source.indexOf("function startEditorSelectionDrag"); + const end = source.indexOf("\n}\n\nfunction executeFromContextMenu", start); + const dragSource = source.slice(start, end); + + expect(start).toBeGreaterThanOrEqual(0); + expect(end).toBeGreaterThan(start); + expect(dragSource).toContain("if (event.shiftKey) return false;"); + expect(dragSource.indexOf("if (event.shiftKey) return false;")).toBeLessThan(dragSource.indexOf("const selection = selectedRangeAtPointer")); + }); +});