[BUG] Going to previous command in terminal editing loses current command (data loss)

Resolved 💬 8 comments Opened Jun 17, 2025 by peterkaminski Closed Jan 5, 2026

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: v1.0.25
  • Operating System: macOS Sonoma 14.7
  • Terminal: iTerm2

Bug Description

As I was creating and editing a multiline command, I used Ctrl-P and Ctrl-N to move between displayed lines in the current command. Using Ctrl-P auto-repeat, I accidentally moved from the current, not-sent command, to the previously issued command. The command I was creating was no longer displayed or accessible with Ctrl-N. The command was about 10 lines long, and contained 3-4 minutes of concentration and careful creation, and it was lost.

Steps to Reproduce

  1. In the Claude Code terminal entry box, issue /clear
  2. Type a multiline prompt.
  3. Use Ctrl-P (and perhaps Ctrl-N) to move to different parts of the draft command to edit.
  4. Use Ctrl-P to back up to the /clear command.
  5. Use Ctrl-N to try to re-enter the draft command.

Expected Behavior

If I'm drafting a command and use Ctrl-P to move to the most recently performed command, I expect the terminal editor to preserve my draft command, and let me use Ctrl-N to move back down into it.

Actual Behavior

I used Ctrl-P within my draft command, and accidentally moved into the most recently performed command, /clear. At that point, I could no longer see my draft command, nor use Ctrl-N to move back to it. My draft command was lost.

Additional Context

My regular shell, zsh, works as I would expect. If I move from a partially completed draft command back in the history with Ctrl-P, I can use Ctrl-N to get back to the partially completed draft command.

I had previously run /terminal-setup in Claude Code to install Shift+Enter key binding for newlines in iTerm 2.

Clunky workaround: For a prompt/command that extends over more than one display line, draft it in a text editor instead of Claude Code, then copy/paste it into Claude Code.

View original on GitHub ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗