Skip to content

Commit

Permalink
feat(editor): Allow tab to accept completion (#5855)
Browse files Browse the repository at this point in the history
⚡ Allow `tab` to accept completion
ivov authored Mar 31, 2023
1 parent f7f9d91 commit 1b8c35a
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import { n8nLang } from '@/plugins/codemirror/n8nLang';
import { highlighter } from '@/plugins/codemirror/resolvableHighlighter';
import { inputTheme } from './theme';
import { forceParse } from '@/utils/forceParse';
import { autocompletion } from '@codemirror/autocomplete';
import { acceptCompletion, autocompletion } from '@codemirror/autocomplete';
import type { IVariableItemSelected } from '@/Interface';
@@ -44,6 +44,7 @@ export default mixins(expressionManager, completionManager, workflowHelpers).ext
autocompletion(),
Prec.highest(
keymap.of([
{ key: 'Tab', run: acceptCompletion },
{
any: (_: EditorView, event: KeyboardEvent) => {
if (event.key === 'Escape') {
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import { mapStores } from 'pinia';
import { EditorView, keymap } from '@codemirror/view';
import { EditorState, Prec } from '@codemirror/state';
import { history, redo } from '@codemirror/commands';
import { autocompletion, completionStatus } from '@codemirror/autocomplete';
import { acceptCompletion, autocompletion, completionStatus } from '@codemirror/autocomplete';
import { useNDVStore } from '@/stores/ndv';
import { workflowHelpers } from '@/mixins/workflowHelpers';
@@ -78,6 +78,7 @@ export default mixins(completionManager, expressionManager, workflowHelpers).ext
inputTheme({ isSingleLine: this.isSingleLine }),
Prec.highest(
keymap.of([
{ key: 'Tab', run: acceptCompletion },
{
any(view: EditorView, event: KeyboardEvent) {
if (event.key === 'Escape' && completionStatus(view.state) !== null) {

0 comments on commit 1b8c35a

Please sign in to comment.