Repository navigation
Terminal copy collapses the pane's padding - #57
Merged
Merged
Conversation
…e across a line break) so a selection drops the pane's padding Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…gation, nothing-selected passthrough) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… reaches Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Text copied from a terminal tile came with every blank cell as a space, so a few copied lines pasted as a block padded out to the pane's width.
Cause
capture-pane -Npads every row to the pane width with written spaces (invariant 4). xterm's copy trims only cells that were never written, so the padding stays in the selection.Change
collapseWhitespace(terminalCore.js) trims the selection, then turns each whitespace run into one space, or one newline if the run spans a line break.ensureTerminaladds a capture-phasecopylistener on the host xterm is opened into. It writes the collapsed selection and stops the event, because xterm's own copy listener sits on its element, inside the host, and would otherwise overwrite the text with the raw selection. With nothing selected, the event is left to the browser.Assumptions to challenge
echo 'a b'pastes asecho 'a b'), and copied code loses its indentation and blank lines. This is the chosen behavior ("collapse, keep line breaks"), not an oversight.Testing
collapseWhitespace.test.js: the transform.terminalCore.test.js"terminal copy": the listener is on the host and uses capture, writes the collapsed text, callspreventDefaultandstopPropagation, and leaves an empty selection alone. RemovingstopPropagation, the capture flag or the selection guard each fails a test.static/distrebuilt and fresh.foo bar\nbaz qux\nlast line.PERISCOPE_TMUX_SOCKETisn't an isolated alternative either, becausetmux_mirrorandtmux_inputignore it.🤖 Generated with Claude Code