[BUG] Claude Code erases a lengthy request in terminal when using up/down arrows
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?
Type a lengthy request with several lines into the chat box on Claude Code.
Use up arrow in the terminal to fix something in the first line. Even if by mistake one more up arrow is pressed, Claude Code erases the entire command/request.
We cannot retrieve it. Please FIX it.
What Should Happen?
Input history navigation (↑ arrow) erases multi-line input instead of allowing line-by-line editing
Description
When composing a multi-line prompt in the Claude Code chat input, pressing the up arrow key to edit an earlier line causes the entire input to be lost and replaced with the previous command from history. There's no way to recover the erased content.
Any of these would help:
- Context-aware history: Only trigger history navigation when input is empty or cursor is at position 0,0
- Confirmation prompt: Add confirmation before replacing non-empty input with history
- Recoverable buffer: Store replaced content in a recoverable buffer (
Ctrl+Shift+Zor similar to restore) - Modifier key requirement: Use
Ctrl+↑/Ctrl+↓for history navigation instead of bare arrow keys (consistent with many IDEs)
Error Messages/Logs
Erases existing command/request
Steps to Reproduce
Steps to Reproduce
- Open Claude Code in terminal
- Type a multi-line request (e.g., 5+ lines describing a complex task)
- While cursor is on line 1, press the up arrow key (either intentionally to move within the text, or accidentally one extra time)
- Observe: entire multi-line input is replaced with previous history entry
- Press down arrow—original input is not recoverable
Expected Behavior
- Up arrow at the first line of input should either:
- Do nothing, OR
- Require a modifier key (e.g.,
Ctrl+↑) to access history, OR - Prompt for confirmation before replacing content
- Multi-line input should be recoverable if accidentally navigated away
Actual Behavior
Single up-arrow keypress immediately and irreversibly replaces all input with history.
Environment
- Claude Code version: <!-- run
claude --version--> - OS: <!-- e.g., macOS 14.x / Ubuntu 24.04 / Windows 11 -->
- Terminal: <!-- e.g., iTerm2, Windows Terminal, native terminal -->
Impact
This is particularly painful when drafting complex, multi-paragraph prompts—losing 5-10 minutes of careful prompt crafting to a single accidental keystroke. High-friction issue for power users who write detailed requests.
Suggested Solutions
Any of these would help:
- Context-aware history: Only trigger history navigation when input is empty or cursor is at position 0,0
- Confirmation prompt: Add confirmation before replacing non-empty input with history
- Recoverable buffer: Store replaced content in a recoverable buffer (
Ctrl+Shift+Zor similar to restore) - Modifier key requirement: Use
Ctrl+↑/Ctrl+↓for history navigation instead of bare arrow keys (consistent with many IDEs)
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.7
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
In terminal, erases typed commands/requests, on up arrow
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗