fix(editor): preserve multi-cursor clicks on identifiers

This commit is contained in:
zipg authored and GitHub committed 2026-08-02 10:08:48 +08:00
1 parent 42d0eedfc7
commit 8379f0d048
3 files changed
+33 -8

No files matched your search

@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { startsQueryEditorRectangularSelection } from "@/lib/editor/queryEditorPointerSelection";
import { startsQueryEditorRectangularSelection, usesQueryEditorObjectNavigationModifier } from "@/lib/editor/queryEditorPointerSelection";
describe("query editor pointer selection", () => {
it("starts rectangular selection for Alt+left drag", () => {
@@ -13,4 +13,18 @@ describe("query editor pointer selection", () => {
it("leaves ordinary left clicks to the normal cursor handler", () => {
expect(startsQueryEditorRectangularSelection({ altKey: false, button: 0 })).toBe(false);
});
it("uses Cmd or Ctrl without Alt for object navigation", () => {
expect(usesQueryEditorObjectNavigationModifier({ altKey: false, ctrlKey: false, metaKey: true })).toBe(true);
expect(usesQueryEditorObjectNavigationModifier({ altKey: false, ctrlKey: true, metaKey: false })).toBe(true);
});
it("leaves Alt+Cmd and Alt+Ctrl to multi-cursor selection", () => {
expect(usesQueryEditorObjectNavigationModifier({ altKey: true, ctrlKey: false, metaKey: true })).toBe(false);
expect(usesQueryEditorObjectNavigationModifier({ altKey: true, ctrlKey: true, metaKey: false })).toBe(false);
});
it("does not treat an unmodified pointer event as object navigation", () => {
expect(usesQueryEditorObjectNavigationModifier({ altKey: false, ctrlKey: false, metaKey: false })).toBe(false);
});
});
@@ -3,6 +3,16 @@ export interface QueryEditorPointerEvent {
button: number;
}
export interface QueryEditorObjectNavigationModifierEvent {
altKey: boolean;
ctrlKey: boolean;
metaKey: boolean;
}
export function startsQueryEditorRectangularSelection(event: QueryEditorPointerEvent): boolean {
return event.altKey || event.button === 1;
}
export function usesQueryEditorObjectNavigationModifier(event: QueryEditorObjectNavigationModifierEvent): boolean {
return !event.altKey && (event.metaKey || event.ctrlKey);
}