Skip to content

Commit

Permalink
feat: Tab key accepts auto-complete suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
kswenson committed Nov 4, 2024
1 parent 15e61d5 commit caa655b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions v3/src/components/common/formula-editor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
autocompletion, closeBrackets, closeBracketsKeymap, Completion, CompletionContext,
acceptCompletion, autocompletion, closeBrackets, closeBracketsKeymap, Completion, CompletionContext,
completionKeymap, CompletionResult, insertCompletionText, pickedCompletion
} from "@codemirror/autocomplete"
import { defaultKeymap } from "@codemirror/commands"
Expand Down Expand Up @@ -232,8 +232,13 @@ function cmExtensionsSetup() {
}),
codapHighlightingViewPlugin,
keymap.of(keymaps.flat()),
Prec.highest( // Overrides CodeMirror's default keymap for Cmd-Enter key
keymap.of([{ key: "Mod-Enter", run: () => true }])
Prec.highest(
keymap.of([
// Tab key accepts auto-complete suggestion (https://discuss.codemirror.net/t/tab-autocompletion/6396)
{ key: "Tab", run: acceptCompletion },
// Prevents CodeMirror's default behavior for Cmd-Enter key
{ key: "Mod-Enter", run: () => true }

Check warning on line 240 in v3/src/components/common/formula-editor.tsx

View check run for this annotation

Codecov / codecov/patch

v3/src/components/common/formula-editor.tsx#L240

Added line #L240 was not covered by tests
])
)
]
return extensions.filter(Boolean)
Expand Down

0 comments on commit caa655b

Please sign in to comment.