fix(sql): preserve file associations and list selection

This commit is contained in:
zipg authored and GitHub committed 2026-08-13 11:44:55 +08:00
1 parent 2e27f7a66a
commit e5a3917f7d
25 files changed
+558 -186

No files matched your search

@@ -0,0 +1,40 @@
import { describe, expect, it } from "vitest";
import { orderedListRangeAnchorIndex, orderedListSelectionIntent } from "@/lib/selection/orderedListSelection";
describe("orderedListSelectionIntent", () => {
it("uses Shift for range selection even when another modifier is also reported", () => {
expect(orderedListSelectionIntent({ shiftKey: true, metaKey: false, ctrlKey: false })).toBe("range");
expect(orderedListSelectionIntent({ shiftKey: true, metaKey: true, ctrlKey: false })).toBe("range");
expect(orderedListSelectionIntent({ shiftKey: true, metaKey: false, ctrlKey: true })).toBe("range");
});
it("uses Cmd or Ctrl for toggle selection", () => {
expect(orderedListSelectionIntent({ shiftKey: false, metaKey: true, ctrlKey: false })).toBe("toggle");
expect(orderedListSelectionIntent({ shiftKey: false, metaKey: false, ctrlKey: true })).toBe("toggle");
});
it("uses an unmodified click for single selection", () => {
expect(orderedListSelectionIntent({ shiftKey: false, metaKey: false, ctrlKey: false })).toBe("single");
});
});
describe("orderedListRangeAnchorIndex", () => {
const items = [
{ type: "file", id: "first" },
{ type: "folder", id: "folder" },
{ type: "file", id: "last" },
];
it("keeps the explicit selection anchor", () => {
expect(orderedListRangeAnchorIndex(items, 2, { type: "file", id: "first" })).toBe(2);
});
it("uses the active item when no explicit anchor exists", () => {
expect(orderedListRangeAnchorIndex(items, null, { type: "folder", id: "folder" })).toBe(1);
});
it("does not fall back to the first item without an anchor", () => {
expect(orderedListRangeAnchorIndex(items, null, null)).toBeNull();
expect(orderedListRangeAnchorIndex(items, null, { type: "file", id: "missing" })).toBeNull();
});
});