claude-code - 💡(How to fix) Fix [Bug] Leading whitespace in drafted text output carries over when copied [1 comments, 2 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#52841Fetched 2026-04-25 06:19:28
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1
RAW_BUFFERClick to expand / collapse

Bug Description Title: Leading whitespace in drafted text output carries over when copied

Description: When Claude Code outputs text that the user intends to copy (emails, messages, drafts, etc.), the output often starts with leading whitespace or indentation. When the text is selected and copied from the terminal, that leading whitespace is included in the clipboard contents and gets pasted into the destination (email client, Slack, etc.), requiring manual cleanup every time.

Steps to reproduce:

  1. Ask Claude Code to write an email or short piece of text
  2. Ask it again to rewrite without any leading formatting/spacing
  3. Select and copy the output from the terminal
  4. Paste into an email client or text editor
  5. Observe leading whitespace at the start of the pasted content

Expected behavior: Drafted text intended to be copied verbatim should start flush-left with no indentation or leading blank characters, so the clipboard content is clean.

Actual behavior: Output consistently includes leading whitespace, even after explicit requests not to include it. The whitespace appears to come from the terminal's rendering/wrapping of assistant text rather than the content itself.

Environment:

  • Claude Code CLI
  • macOS (Darwin 25.4.0)
  • Shell: zsh

Impact: Minor but recurring friction — every drafted message needs manual whitespace cleanup before sending.

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.119
  • Feedback ID: cddab0bc-d918-4859-9061-36a6734c4686

Errors

extent analysis

TL;DR

Removing leading whitespace from the output text before copying it may resolve the issue.

Guidance

  • Verify that the issue is not specific to the terminal or shell being used by testing with a different terminal emulator or shell.
  • Check if there are any configuration options in Claude Code CLI to remove leading whitespace from output text.
  • Consider using a text processing tool or command to remove leading whitespace before copying the text.
  • Investigate if the issue is related to the rendering or wrapping of text in the terminal, and if there are any settings that can be adjusted to prevent this.

Example

No code snippet is provided as the issue does not imply a specific code-related solution.

Notes

The issue may be specific to the combination of Claude Code CLI, macOS, and iTerm.app, and may not occur in other environments. Further investigation is needed to determine the root cause.

Recommendation

Apply workaround: Remove leading whitespace from the output text before copying it, as this is a minor but recurring issue that can be mitigated with a simple text processing step.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [Bug] Leading whitespace in drafted text output carries over when copied [1 comments, 2 participants]