fix(cli): ignore unmapped vim normal keys (#27102)

This commit is contained in:
Mukunda Rao Katta
2026-05-27 10:03:00 -07:00
committed by GitHub
parent 41c9260cae
commit 5cac7c10fa
2 changed files with 28 additions and 2 deletions
@@ -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();
},
);
});
+8 -2
View File
@@ -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;
}