fix(editor): keep shift-click selection in query editor

This commit is contained in:
zipg authored and GitHub committed 2026-09-04 09:49:54 +08:00
1 parent 06dcd0013c
commit 97f5a37ba8
2 files changed
+18

No files matched your search

@@ -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;
@@ -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"));
});
});