diff --git a/patches/@replit__codemirror-vim-core@0.1.0.patch b/patches/@replit__codemirror-vim-core@0.1.0.patch index 3324edc5ed..930848ddcf 100644 --- a/patches/@replit__codemirror-vim-core@0.1.0.patch +++ b/patches/@replit__codemirror-vim-core@0.1.0.patch @@ -22,7 +22,16 @@ diff --git a/vim.js b/vim.js { keys: 'a', type: 'motion', motion: 'textObjectManipulation' }, { keys: 'i', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true }}, // Search -@@ -2582,6 +2589,8 @@ +@@ -1974,6 +1981,8 @@ + if (command.type == 'keyToEx') { + // Handle user defined Ex to Ex mappings + exCommandDispatcher.processCommand(cm, command.exArgs.input); ++ // OpenIDEA: end the command like the `:` prompt does, so the typed keys leave the status. ++ if (cm.state.vim) clearInputState(cm); + } else { + /**@type{import("./types").PromptOptions} */ + var promptOptions = { +@@ -2582,6 +2591,8 @@ if (head.sticky == "before") head.ch--; return head; }, @@ -31,7 +40,7 @@ diff --git a/vim.js b/vim.js textObjectManipulation: function(cm, head, motionArgs, vim) { // TODO: lots of possible exceptions that can be thrown here. Try da( // outside of a () block. -@@ -3423,6 +3432,8 @@ +@@ -3423,6 +3434,8 @@ cm.replaceSelection(text); } }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0bfd529961..a22fe42c57 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,7 +11,7 @@ patchedDependencies: '@codemirror/language@6.13.1': eb0f811cd8918704234484dcb1f6740e5cd133ac639d82b968e5b87ae992b9dc '@codemirror/view': bcc394e0b3a7448b934ebb02620609bd95feb4ef66112bc6aad0a23ef0af3589 '@lezer/lr': 1561ac9e9bbbc302f48ea274ae33602e598a7833edaadd7031559c893c7853b8 - '@replit/codemirror-vim-core@0.1.0': e502665b2969d19575a5671f9555ed0433a92fb42ae5f92121ef355c04b8f49c + '@replit/codemirror-vim-core@0.1.0': 9342a63bb360d0e59c906874d06f35281b15f933a43889566f74554fe12d3263 importers: @@ -3752,7 +3752,7 @@ snapshots: '@lezer/highlight': 1.2.5 '@lezer/lr': 1.4.11(patch_hash=1561ac9e9bbbc302f48ea274ae33602e598a7833edaadd7031559c893c7853b8) - '@replit/codemirror-vim-core@0.1.0(patch_hash=e502665b2969d19575a5671f9555ed0433a92fb42ae5f92121ef355c04b8f49c)': {} + '@replit/codemirror-vim-core@0.1.0(patch_hash=9342a63bb360d0e59c906874d06f35281b15f933a43889566f74554fe12d3263)': {} '@replit/codemirror-vim@6.4.0(@codemirror/commands@6.11.1)(@codemirror/language@6.13.1(patch_hash=eb0f811cd8918704234484dcb1f6740e5cd133ac639d82b968e5b87ae992b9dc))(@codemirror/search@6.7.2)(@codemirror/state@6.7.6)(@codemirror/view@6.44.2(patch_hash=bcc394e0b3a7448b934ebb02620609bd95feb4ef66112bc6aad0a23ef0af3589))': dependencies: @@ -3761,7 +3761,7 @@ snapshots: '@codemirror/search': 6.7.2 '@codemirror/state': 6.7.6 '@codemirror/view': 6.44.2(patch_hash=bcc394e0b3a7448b934ebb02620609bd95feb4ef66112bc6aad0a23ef0af3589) - '@replit/codemirror-vim-core': 0.1.0(patch_hash=e502665b2969d19575a5671f9555ed0433a92fb42ae5f92121ef355c04b8f49c) + '@replit/codemirror-vim-core': 0.1.0(patch_hash=9342a63bb360d0e59c906874d06f35281b15f933a43889566f74554fe12d3263) '@rolldown/binding-android-arm-eabi@1.2.14': optional: true diff --git a/src/features/vim/__tests__/vim.test.ts b/src/features/vim/__tests__/vim.test.ts index 3cb9888111..416aaab22a 100644 --- a/src/features/vim/__tests__/vim.test.ts +++ b/src/features/vim/__tests__/vim.test.ts @@ -262,6 +262,35 @@ describe("Vim engine", () => { view.destroy(); }); + it.each([ + ["gd", "navigate.declaration"], + ["gi", "navigate.implementation"], + ])("ends the command after an mapping (%s)", async (lhs, id) => { + const d = registerAction({ id, title: id, run: () => void ran.push(id) }); + const view = makeView(); + const cm = getCM(view)!; + applyRcCommands( + parseVimrc(`nnoremap gd (GotoDeclaration)\nnnoremap gi (GotoImplementation)`).commands, + ); + // Through keydown: the view plugin, not Vim.handleKey, keeps the typed keys in `status`. + const press = (key: string) => + view.contentDOM.dispatchEvent(new KeyboardEvent("keydown", { key, bubbles: true, cancelable: true })); + press(lhs[0]!); + await tick(); + // `g` alone is only a prefix of the mapping. + expect(ran).toEqual([]); + press(lhs[1]!); + await tick(); + expect(ran).toEqual([id]); + // A leftover status draws the half-height pending cursor until the next command. + expect(cm.state.vim!.status).toBe(""); + expect(cm.state.vim!.inputState.keyBuffer).toEqual([]); + expect(cm.state.vim!.insertMode).toBe(false); + applyRcCommands([]); + view.destroy(); + d(); + }); + it.each([ ['let mapleader = " "', ["", "f", "f"]], ['let mapleader = ","', [",", "f", "f"]],