fix(#290): route clipboard paste into active overlay buffer#292
Merged
Conversation
When the user was at the command prompt (or rename / window-index prompt) and pasted from the clipboard, Event::Paste was unconditionally forwarded to the active pane via send-paste while the per-char Key events that some terminals emit alongside the paste went into the overlay buffer. Net result: the paste landed in both the prompt and the underlying shell. Route Event::Paste through a new route_paste_to_overlay helper that inserts into command_buf / rename_buf / pane_title_buf / window_idx_buf when the corresponding overlay is active, and only emits send-paste when no overlay consumed it. On Windows, crossterm with EnableBracketedPaste emits Event::Paste AND per-char Event::Key events for one Ctrl+V. The existing paste_suppress_until window already silenced the duplicate Key events on the passthrough path; extend the same gate to the four overlay Char arms so the duplicates do not double-insert when an overlay consumed the paste. Includes 7 unit tests covering the helper's routing behaviour. Closes #290
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes clipboard paste routing so paste data is consumed by active client-side overlays instead of also being forwarded to the underlying pane.
Changes:
- Adds
route_paste_to_overlayto route paste data into command, rename, pane-title, and window-index buffers. - Updates
Event::Pastehandling to skipsend-pastewhen an overlay consumes the paste. - Adds unit tests for overlay paste routing behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/client.rs |
Adds paste routing helper and integrates it into event handling. |
tests-rs/test_client.rs |
Adds tests covering paste routing into overlay buffers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
Summary
Pasting into tmux's command prompt (
prefix + :) was leaking the clipboard contents into both the prompt and the underlying shell. Same bug shape for the rename / pane-title / window-index prompts.Root cause (client.rs):
Event::Pastewas unconditionally forwarded to the active pane viasend-paste, regardless of whether a client-side text-input overlay was open.Event::Keyevents alongsideEvent::Paste(notably Windows Terminal with bracketed paste), the duplicate Key events were also being inserted into the overlay buffer. Net effect: paste appeared in both places.Fix
route_paste_to_overlayhelper that inserts paste data intocommand_buf/rename_buf/pane_title_buf/window_idx_buf(digits only) when the corresponding overlay is active, and returnsfalseso the caller falls back tosend-pastewhen no overlay is open.Event::Pastenow calls the helper and only forwards viasend-pastewhen nothing consumed it.paste_suppress_untilwindow already silenced the duplicate Key events on the passthrough path; extended the same gate to the four overlayChararms via a newpaste_burst_activelocal so the duplicates don't double-insert when an overlay consumed the paste.Tests
7 new unit tests in
tests-rs/test_client.rscover the helper:false(caller forwards viasend-paste)All 7 pass; the 41 existing paste-related tests still pass;
cargo build --bin psmuxis clean.Test plan
cargo build --bin psmuxcargo test --bin psmux paste(48 tests pass)prefix + :, paste from clipboard — text lands only in the prompt, shell stays untouchedprefix + ,(rename window) and paste — text lands only in the rename bufferCloses #290