Paste drops newlines when running inside tmux (content joins in input box)
Summary
When Claude Code runs inside a tmux session, pasting multi-line text via the terminal's normal paste gesture (e.g., Ctrl+Shift+V) produces single-line output in the input box — newlines between lines are silently stripped. The same paste works correctly when Claude Code is run directly in the terminal (no tmux).
Environment
- Claude Code: 2.1.117
- tmux: 3.5a
- Terminal: Ghostty (snap)
- OS: Ubuntu 22.04 on Wayland
Reproduction
- Load a known multi-line clipboard:
````
printf 'AAA\nBBB\nCCC' | wl-copy
- Start a fresh
claudesession inside tmux. - Click into the input box, press Ctrl+Shift+V, do not press Enter.
- Observed: input box displays a single line
AAABBBCCC. - Expected: input box displays three lines
AAA/BBB/CCC.
If submitted, the message arrives as \"AAABBBCCC\" in the session transcript (verified by inspecting ~/.claude/projects/<proj>/<session>.jsonl).
Isolation (the bug is in Claude Code's BP handler under tmux)
| Path | Result |
|===|===|
| Outside tmux: Ctrl+Shift+V paste into Claude Code | Newlines preserved |
| Inside tmux: Ctrl+Shift+V paste into Claude Code | Newlines stripped, content joined |
| Inside tmux: typed Shift+Enter into Claude Code | Newlines preserved |
| Inside tmux: paste into cat with BP mode enabled | Bytes arrive as \e[200~AAA\nBBB\nCCC\e[201~ — correct |
| Inside tmux: tmux paste-buffer -p of identical BP-wrapped bytes into Claude Code's pane | Newlines preserved |
So the terminal and tmux deliver a correct bracketed-paste sequence to Claude Code's pty — the BP start/end markers are intact and the \n bytes between them are intact — but Claude Code's BP handler collapses the content when this specific delivery path (user Ctrl+Shift+V → terminal → tmux → Claude Code) is used.
Byte-level capture
Captured inside tmux by enabling bracketed paste on a test tty and running cat:
printf '\e[?2004h' > /dev/tty
cat > /tmp/paste3.bin
# Ctrl+Shift+V paste of AAA\nBBB\nCCC, Ctrl+D
printf '\e[?2004l' > /dev/tty
od -c /tmp/paste3.bin
Output:
0000000 033 [ 2 0 0 ~ A A A \n B B B \n C C
0000020 C 033 [ 2 0 1 ~ \n
i.e. \e[200~AAA\nBBB\nCCC\e[201~ — the exact standard BP-wrapped sequence.
Note on the apparent discrepancy with tmux paste-buffer
Feeding that same byte sequence to the pane via tmux send-keys -H (literal bytes) or tmux paste-buffer -p preserves newlines correctly in Claude Code. Only the user-initiated paste path produces the join. This suggests the handler may be sensitive to pty read chunking or timing characteristic of real paste delivery that tmux's synthetic paste does not reproduce.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗