[BUG] Vim mode: Esc during a pending permission/approval dialog rejects the dialog instead of exiting insert mode, discarding typed text
Status Open
Reported on v2.1.273
Maintainer reply None cached
Workaround ✓ Mentioned in description ↑
Activity 0 comments · opened Sep 24, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
While vim mode is enabled and a permission/approval dialog is pending (e.g. the plan-approval prompt from ExitPlanMode), pressing Esc to exit INSERT mode in the text input is instead captured by the dialog and interpreted as "reject/decline." The dialog closes and whatever text was being composed is silently discarded.
What Should Happen?
Esc should behave the same as it does outside of a pending dialog: exit INSERT mode and return to NORMAL mode within the text input, preserving the in-progress text. The dialog's own reject/cancel handling shouldn't take priority over vim-mode's Esc while the user is actively editing text.
Error Messages/Logs
None — this isn't a crash or visible error. The dialog simply closes and the typed text disappears with no warning, confirmation, or way to recover it.
Steps to Reproduce
- Enable vim keybindings (/config → editor mode → vim).
- Get Claude Code into a state where a permission/approval dialog is shown and stays pending — e.g. ask it to enter plan mode, have it write a plan, then have it call ExitPlanMode.
- While the dialog is showing, click into the input box and start typing a multi-line comment/response (entering vim INSERT mode).
- Press Esc, intending to switch to vim NORMAL mode so you can edit what you typed.
- Observe: the pending dialog is rejected instead, and the typed text is gone.
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.273
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
- Scope: this was reproduced specifically with ExitPlanMode's plan-approval dialog, but the same input-box-stays-open-while-a-dialog-is-pending pattern likely applies to any permission/approval prompt (e.g. a Bash command approval), not just plan approval — worth checking whether it's general.
- Suggested fix: while the input has focus and vim mode is in INSERT state, Esc should switch to NORMAL mode first, rather than being routed to the dialog's reject handler. The dialog's Esc-to-reject behavior could still apply when the input is empty or not in INSERT mode.
- Workaround in the meantime: avoid typing into the input box while a dialog is actively pending — finish composing a message before triggering the action that opens the dialog, or compose longer text externally and paste it in once the dialog is resolved.