claude-code - 💡(How to fix) Fix Ctrl+Z suspend wipes undo buffer, making accidental deletions unrecoverable [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46211Fetched 2026-04-11 06:26:13
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

Suspending Claude Code with Ctrl+Z and resuming with fg completely wipes the input undo buffer. This means the most natural recovery instinct after an accidental destructive edit (e.g. Ctrl+K deleting a long prompt) actually destroys the only way to recover it.

Root Cause

  1. Not undoing the destructive edit (because Ctrl+Z suspends instead)
  2. Destroying the undo history that could have recovered it (because suspend/resume wipes the buffer)
RAW_BUFFERClick to expand / collapse

Summary

Suspending Claude Code with Ctrl+Z and resuming with fg completely wipes the input undo buffer. This means the most natural recovery instinct after an accidental destructive edit (e.g. Ctrl+K deleting a long prompt) actually destroys the only way to recover it.

Steps to reproduce

  1. Start typing a long prompt (1000+ chars)
  2. Accidentally press Ctrl+K (kills to end of line), deleting most of your input
  3. Instinctively press Ctrl+Z to undo — but this suspends Claude Code instead
  4. Type fg to resume Claude Code
  5. Press Ctrl+_ (the actual undo binding) — nothing happens, undo history is gone

Expected behavior

  • The undo buffer should survive SIGTSTP/SIGCONT (suspend/resume)
  • After fg, Ctrl+_ should still be able to undo prior edits

Actual behavior

The undo buffer is completely wiped on resume. The text deleted by Ctrl+K is permanently lost.

Why this is particularly painful

Ctrl+Z is the universal undo shortcut in virtually every other text editor. When a user accidentally destroys input, muscle memory fires Ctrl+Z before conscious thought kicks in. In Claude Code, this has the perverse effect of:

  1. Not undoing the destructive edit (because Ctrl+Z suspends instead)
  2. Destroying the undo history that could have recovered it (because suspend/resume wipes the buffer)

So the instinct to recover from a mistake actively makes the mistake unrecoverable.

Additional notes

  • Related issues: #8626, #6298, #3195, #12483

Environment

  • macOS (Darwin 24.6.0)
  • zsh

extent analysis

TL;DR

The issue can be mitigated by using a different undo shortcut or avoiding the use of Ctrl+Z to suspend Claude Code.

Guidance

  • Avoid using Ctrl+Z to undo edits in Claude Code, as it suspends the program and wipes the undo buffer; instead, use the actual undo binding Ctrl+_
  • When a destructive edit occurs, try to consciously use Ctrl+_ to undo before suspending or resuming Claude Code
  • Consider using a different shortcut for suspending Claude Code to avoid conflicts with the universal undo shortcut
  • Review related issues (#8626, #6298, #3195, #12483) for potential workarounds or fixes

Example

No code snippet is provided as it is not clearly supported by the issue.

Notes

This guidance assumes that the issue is specific to the combination of Claude Code, macOS, and zsh, and may not apply to other environments or configurations.

Recommendation

Apply workaround: use a different undo shortcut or avoid using Ctrl+Z to suspend Claude Code, as this is a safer and more reliable solution until a fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

  • The undo buffer should survive SIGTSTP/SIGCONT (suspend/resume)
  • After fg, Ctrl+_ should still be able to undo prior edits

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING