Skip to content

fix(#290): route clipboard paste into active overlay buffer#292

Merged
tarikguney merged 2 commits into
masterfrom
fix/290-paste-leaks-into-shell
May 19, 2026
Merged

fix(#290): route clipboard paste into active overlay buffer#292
tarikguney merged 2 commits into
masterfrom
fix/290-paste-leaks-into-shell

Conversation

@tarikguney

@tarikguney tarikguney commented May 13, 2026

Copy link
Copy Markdown
Collaborator

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::Paste was unconditionally forwarded to the active pane via send-paste, regardless of whether a client-side text-input overlay was open.
  • On terminals that emit per-char Event::Key events alongside Event::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

  • Extracted a small route_paste_to_overlay helper that inserts paste data into command_buf / rename_buf / pane_title_buf / window_idx_buf (digits only) when the corresponding overlay is active, and returns false so the caller falls back to send-paste when no overlay is open.
  • Event::Paste now calls the helper and only forwards via send-paste when nothing consumed it.
  • On Windows, the existing paste_suppress_until window already silenced the duplicate Key events on the passthrough path; extended the same gate to the four overlay Char arms via a new paste_burst_active local so the duplicates don't double-insert when an overlay consumed the paste.

Tests

7 new unit tests in tests-rs/test_client.rs cover the helper:

  • paste into command prompt inserts at cursor (start + mid-buffer)
  • no-overlay returns false (caller forwards via send-paste)
  • rename / pane-title prompts append
  • window-index prompt keeps only digits
  • command_input takes precedence when multiple overlay flags are set

All 7 pass; the 41 existing paste-related tests still pass; cargo build --bin psmux is clean.

Test plan

  • cargo build --bin psmux
  • cargo test --bin psmux paste (48 tests pass)
  • Manual: open prefix + :, paste from clipboard — text lands only in the prompt, shell stays untouched
  • Manual: same flow under Windows Terminal (bracketed paste path)
  • Manual: open prefix + , (rename window) and paste — text lands only in the rename buffer

Closes #290

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_overlay to route paste data into command, rename, pane-title, and window-index buffers.
  • Updates Event::Paste handling to skip send-paste when 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.

Comment thread src/client.rs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@tarikguney tarikguney requested a review from psmux May 15, 2026 20:02
@tarikguney tarikguney closed this May 18, 2026
@tarikguney tarikguney reopened this May 18, 2026
@tarikguney tarikguney merged commit c1f2f4f into master May 19, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minor Issue when pasting from clipboard into tmux's command mode

2 participants