From 2bb3b71a704a1790c99da15baf1b4a160c668b19 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Wed, 8 Sep 2021 19:51:43 +0530 Subject: [PATCH] refactor: map ctrl-space to autocomplete by default in codemirror --- helpers/editor/codemirror.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/helpers/editor/codemirror.ts b/helpers/editor/codemirror.ts index bd5e8a991..e1e8791a3 100644 --- a/helpers/editor/codemirror.ts +++ b/helpers/editor/codemirror.ts @@ -41,6 +41,9 @@ const DEFAULT_EDITOR_CONFIG: CodeMirror.EditorConfiguration = { foldGutter: true, autoCloseBrackets: true, gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], + extraKeys: { + "Ctrl-Space": "autocomplete", + } } /** @@ -128,12 +131,12 @@ export function useCodemirror( } }) - /* TODO: Show autocomplete on typing (this is just for testing) */ - cm.value.on("keyup", (instance, event) => { - if (!instance.state.completionActive && event.key !== "Enter") { - instance.showHint() - } - }) + // /* TODO: Show autocomplete on typing (this is just for testing) */ + // cm.value.on("keyup", (instance, event) => { + // if (!instance.state.completionActive && event.key !== "Enter") { + // instance.showHint() + // } + // }) }) const setTheme = () => {