diff --git a/src/index.ts b/src/index.ts index 2eeb01f..9833b22 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,6 +15,7 @@ import { EditorView, showPanel, Panel, + keymap, } from "@codemirror/view"; import { setSearchQuery } from "@codemirror/search"; @@ -216,7 +217,7 @@ const vimPlugin = ViewPlugin.fromClass( let isCopy = key === "" && !CodeMirror.isMac; if (isCopy && cm.somethingSelected()) { this.waitForCopy = true; - return true; + return false; } vim.status = (vim.status || "") + key; @@ -280,12 +281,18 @@ const vimPlugin = ViewPlugin.fromClass( this.useNextTextInput = true; } else { this.useNextTextInput = false; - this.handleKey(e, view); } }, }, - provide: () => { + provide: (plugin) => { return [ + keymap.of([ + { + any: function(view: EditorView, e: KeyboardEvent) { + return !!view.plugin(plugin)?.handleKey(e, view); + } + } + ]), EditorView.inputHandler.of((view, from, to, text) => { var cm = getCM(view); if (!cm) return false; diff --git a/test/webtest-vim.js b/test/webtest-vim.js index 217b947..98e35d8 100644 --- a/test/webtest-vim.js +++ b/test/webtest-vim.js @@ -7,6 +7,7 @@ import { indentUnit } from "@codemirror/language"; import { EditorState } from "@codemirror/state"; import {indentWithTab} from "@codemirror/commands"; import { keymap } from "@codemirror/view"; +import { autocompletion } from "@codemirror/autocomplete" /**@type {any}*/ var disabled = { @@ -46,6 +47,7 @@ describe("Vim extension", () => { extensions: [ vim({}), basicSetup, + autocompletion({activateOnTyping: false}), options.mode == "xml" ? xml() : javascript(), EditorState.tabSize.of(options.tabSize || 4), indentUnit.of(