From 5cac7c10fa9ff34e99553057631727c95c1e99f8 Mon Sep 17 00:00:00 2001 From: Mukunda Rao Katta Date: Wed, 27 May 2026 10:03:00 -0700 Subject: [PATCH] fix(cli): ignore unmapped vim normal keys (#27102) --- .../cli/src/ui/hooks/vim-passthrough.test.tsx | 20 +++++++++++++++++++ packages/cli/src/ui/hooks/vim.ts | 10 ++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/ui/hooks/vim-passthrough.test.tsx b/packages/cli/src/ui/hooks/vim-passthrough.test.tsx index c02b4b2823..a26e53109b 100644 --- a/packages/cli/src/ui/hooks/vim-passthrough.test.tsx +++ b/packages/cli/src/ui/hooks/vim-passthrough.test.tsx @@ -81,4 +81,24 @@ describe('useVim passthrough', () => { expect(handled).toBe(false); }); + + it.each(['H', 'M', 'Q', 'm'])( + 'should ignore unmapped printable key %s in NORMAL mode', + async (sequence) => { + mockVimContext.vimMode = 'NORMAL'; + const { result } = await renderHook(() => + useVim(mockBuffer as TextBuffer), + ); + + let handled = false; + act(() => { + handled = result.current.handleInput( + createKey({ name: sequence, sequence, insertable: true }), + ); + }); + + expect(handled).toBe(true); + expect(mockBuffer.handleInput).not.toHaveBeenCalled(); + }, + ); }); diff --git a/packages/cli/src/ui/hooks/vim.ts b/packages/cli/src/ui/hooks/vim.ts index 9e0006ea53..9083b60181 100644 --- a/packages/cli/src/ui/hooks/vim.ts +++ b/packages/cli/src/ui/hooks/vim.ts @@ -1486,8 +1486,14 @@ export function useVim(buffer: TextBuffer, onSubmit?: (value: string) => void) { // Unknown command, clear count and pending states dispatch({ type: 'CLEAR_PENDING_STATES' }); - // Ignore any Insertable key in Normal Mode - if (normalizedKey.insertable) { + // Ignore unmapped Insertable keys in Normal Mode, but let + // modifier-key chords (ctrl/alt/cmd) fall through to other handlers. + if ( + normalizedKey.insertable && + !normalizedKey.ctrl && + !normalizedKey.alt && + !normalizedKey.cmd + ) { return true; }