Merge pull request #11104 from Budibase/feature/binding-ux-updates

Select autocomplete option on Tab key press.
This commit is contained in:
deanhannigan 2023-07-17 14:11:32 +01:00 committed by GitHub
commit 46d2a7e286
1 changed files with 21 additions and 2 deletions

View File

@ -7,6 +7,8 @@
closeBrackets,
completionKeymap,
closeBracketsKeymap,
acceptCompletion,
completionStatus,
} from "@codemirror/autocomplete"
import {
EditorView,
@ -34,7 +36,8 @@
defaultKeymap,
historyKeymap,
history,
indentWithTab,
indentMore,
indentLess,
} from "@codemirror/commands"
import { Compartment } from "@codemirror/state"
import { javascript } from "@codemirror/lang-javascript"
@ -107,6 +110,22 @@
let isDark = !currentTheme.includes("light")
let themeConfig = new Compartment()
const indentWithTabCustom = {
key: "Tab",
run: view => {
if (completionStatus(view.state) == "active") {
acceptCompletion(view)
return true
}
indentMore(view)
return true
},
shift: view => {
indentLess(view)
return true
},
}
const buildKeymap = () => {
const baseMap = [
...closeBracketsKeymap,
@ -114,7 +133,7 @@
...historyKeymap,
...foldKeymap,
...completionKeymap,
indentWithTab,
indentWithTabCustom,
]
return baseMap
}