feat(editor): add double-click string selection mode option

This commit is contained in:
zipg authored and GitHub committed 2026-09-28 13:14:06 +08:00
1 parent 403da04d1f
commit f76cb4e46b
21 files changed
+153

No files matched your search

@@ -162,6 +162,20 @@ describe("query editor SQL string mouse selection", () => {
expect(selection && doc.slice(selection.main.from, selection.main.to)).toBe("%%");
});
it("returns null when the caller opted into plain word selection", () => {
const doc = "EXEC sp_executesql N'SELECT * FROM my_table WHERE a = 1';";
const state = EditorState.create({ doc });
const view = fakeView(state).view;
const insideString = eventAt(doc.indexOf("my_table"));
const outsideString = eventAt(doc.indexOf("sp_executesql"));
expect(createQueryEditorStringMouseSelection(view, insideString)).not.toBeNull();
expect(createQueryEditorStringMouseSelection(view, insideString, { selectStringContent: false })).toBeNull();
expect(createQueryEditorStringMouseSelection(view, outsideString, { selectStringContent: false })).toBeNull();
// Explicitly asking for the historical behaviour keeps working.
expect(createQueryEditorStringMouseSelection(view, insideString, { selectStringContent: true })).not.toBeNull();
});
it("trimSqlStringWildcardBoundaries shrinks past boundary wildcards only", () => {
const doc = "%a_b%";
expect(trimSqlStringWildcardBoundaries(doc, { from: 0, to: doc.length })).toEqual({ from: 1, to: 4 });