diff options
| author | Justin Mahood <[email protected]> | 2025-08-05 16:29:37 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-05 23:29:37 +0000 |
| commit | 91035ad7b0a6d976c003f37fef9513da8f3635e9 (patch) | |
| tree | 39234632a5c2fa23e3212cb9e6429cf1474c1922 /packages/cli/src/ui/hooks/vim.ts | |
| parent | 12a9bc3ed94fab3071529b5304d46bcc5b4fe756 (diff) | |
Fix(vim): Fix shell mode in Vim mode (#5567)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/hooks/vim.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/vim.ts | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/packages/cli/src/ui/hooks/vim.ts b/packages/cli/src/ui/hooks/vim.ts index cb65e1ee..97b73121 100644 --- a/packages/cli/src/ui/hooks/vim.ts +++ b/packages/cli/src/ui/hooks/vim.ts @@ -260,7 +260,8 @@ export function useVim(buffer: TextBuffer, onSubmit?: (value: string) => void) { normalizedKey.name === 'tab' || (normalizedKey.name === 'return' && !normalizedKey.ctrl) || normalizedKey.name === 'up' || - normalizedKey.name === 'down' + normalizedKey.name === 'down' || + (normalizedKey.ctrl && normalizedKey.name === 'r') ) { return false; // Let InputPrompt handle completion } @@ -270,6 +271,11 @@ export function useVim(buffer: TextBuffer, onSubmit?: (value: string) => void) { return false; // Let InputPrompt handle clipboard functionality } + // Let InputPrompt handle shell commands + if (normalizedKey.sequence === '!' && buffer.text.length === 0) { + return false; + } + // Special handling for Enter key to allow command submission (lower priority than completion) if ( normalizedKey.name === 'return' && @@ -399,10 +405,14 @@ export function useVim(buffer: TextBuffer, onSubmit?: (value: string) => void) { // Handle NORMAL mode if (state.mode === 'NORMAL') { - // Handle Escape key in NORMAL mode - clear all pending states + // If in NORMAL mode, allow escape to pass through to other handlers + // if there's no pending operation. if (normalizedKey.name === 'escape') { - dispatch({ type: 'CLEAR_PENDING_STATES' }); - return true; // Handled by vim + if (state.pendingOperator) { + dispatch({ type: 'CLEAR_PENDING_STATES' }); + return true; // Handled by vim + } + return false; // Pass through to other handlers } // Handle count input (numbers 1-9, and 0 if count > 0) |
