Skip to content

Commit 6e2081f

Browse files
committed
Autocomplete enums
1 parent 6066938 commit 6e2081f

File tree

4 files changed

+237
-221
lines changed

4 files changed

+237
-221
lines changed

apps/webapp/app/components/code/TSQLEditor.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { sql, StandardSQL } from "@codemirror/lang-sql";
2-
import { autocompletion } from "@codemirror/autocomplete";
2+
import { autocompletion, startCompletion } from "@codemirror/autocomplete";
33
import { linter, lintGutter } from "@codemirror/lint";
4+
import { EditorView } from "@codemirror/view";
45
import type { ViewUpdate } from "@codemirror/view";
56
import { CheckIcon, ClipboardIcon, SparklesIcon, TrashIcon } from "@heroicons/react/20/solid";
67
import {
@@ -103,6 +104,23 @@ export function TSQLEditor(opts: TSQLEditorProps) {
103104
maxRenderedOptions: 50,
104105
})
105106
);
107+
108+
// Trigger autocomplete when ' is typed in value context
109+
// CodeMirror's activateOnTyping only triggers on alphanumeric characters,
110+
// so we manually trigger for quotes after comparison operators
111+
exts.push(
112+
EditorView.domEventHandlers({
113+
keyup: (event, view) => {
114+
// Trigger on quote key (both ' and shift+' on some keyboards)
115+
if (event.key === "'" || event.key === '"' || event.code === "Quote") {
116+
setTimeout(() => {
117+
startCompletion(view);
118+
}, 50);
119+
}
120+
return false;
121+
},
122+
})
123+
);
106124
}
107125

108126
// Add TSQL linter

apps/webapp/app/components/code/tsql/tsqlCompletion.test.ts

Lines changed: 0 additions & 172 deletions
This file was deleted.

0 commit comments

Comments
 (0)