Skip to content

fix: paste with Ctrl+V into Search & Replace fields (#1960)#1979

Open
sinelaw wants to merge 1 commit into
masterfrom
claude/wonderful-archimedes-H2xp2
Open

fix: paste with Ctrl+V into Search & Replace fields (#1960)#1979
sinelaw wants to merge 1 commit into
masterfrom
claude/wonderful-archimedes-H2xp2

Conversation

@sinelaw

@sinelaw sinelaw commented May 14, 2026

Copy link
Copy Markdown
Owner

Fixes #1960.

Problem

The project Search & Replace panel (Command Palette → "Search and Replace in Project") runs the focused buffer in a search-replace-list mode whose host-side text-input handler in app/input.rs swallows every Ctrl/Alt-modified key. As a result Ctrl+V never reached the Paste action and users could not paste into the search or replace fields — a real blocker for any non-typable input (UTF-8 characters, long values from outside the editor, regexes, etc.).

Fix

Three small changes, all confined to host-side input/clipboard routing:

  1. app/input.rs text-input-mode handler — when a Ctrl/Alt-modified character key reaches the text-input bypass, resolve it against the Normal context first and let only Action::Paste through. Other normal bindings (Ctrl+O open-file, Ctrl+S save, …) stay blocked, so the search field is not promoted to a global command bar.
  2. app/input.rs Action::Paste handler — route paste through the focused widget input before the editing_disabled guard, since the Search & Replace results buffer is a read-only virtual buffer and the existing guard would otherwise short-circuit.
  3. app/clipboard.rs::paste_text + app/plugin_dispatch.rs — when the active buffer hosts a widget panel with a focused text widget, paste into the widget via a new paste_into_focused_widget helper. Newlines are flattened to spaces for single-line widgets; multi-line widgets receive the clipboard text verbatim.

The fix preserves the original safety property of the text-input-mode bypass (random Ctrl-shortcuts cannot leak through) by allowing only the Paste action.

Tests

Two new e2e tests in tests/e2e/search_replace.rs:

  • test_search_replace_paste_into_search_field — set the internal clipboard to "jovial", open the panel, press Ctrl+V, assert the search field contains "jovial".
  • test_search_replace_paste_into_replace_field — same flow but Tab to the replace field first.

Both tests hang on master (the action never fires, so "jovial" never appears on the screen) and pass with this change. Manual validation in tmux: copying "hello" from the buffer, opening Search & Replace, clearing the prefilled field, and pressing Ctrl+V successfully populates the search field and finds the expected match.

Test plan

  • cargo test -p fresh-editor --test e2e_tests search_replace — 25 pass / 2 ignored
  • cargo test -p fresh-editor --test e2e_tests paste — 63 pass / 2 ignored
  • cargo check --all-targets -p fresh-editor — clean
  • cargo fmt --check — clean
  • Manual tmux validation against the release binary

Generated by Claude Code

The project Search & Replace panel runs in a buffer-local
`search-replace-list` mode that captures printable keys for inline
editing. The text-input-mode handler in `app/input.rs` blocked every
Ctrl/Alt-modified key so Ctrl+V never reached the Paste action, leaving
users unable to paste UTF-8 or other non-typable text into the search
or replace fields.

This change resolves Ctrl+V (and any user-rebound paste key) against
the Normal context from within text-input modes and lets only the
Paste action through — other normal bindings (Ctrl+O, Ctrl+S, …) stay
blocked so a search field isn't promoted to a global command bar.

Paste then routes into the focused widget input via a new helper
(`paste_into_focused_widget`) rather than the underlying read-only
virtual buffer. The Action::Paste handler in `app/input.rs` checks for
a focused widget input before the `editing_disabled` guard so the
read-only Search/Replace results buffer doesn't short-circuit the
paste. Newlines are flattened to spaces for single-line widgets;
multi-line widgets receive the clipboard text verbatim.

Adds two e2e tests covering paste into the search field and into the
replace field after Tab.
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.

Unable to paste value for search in "Search and Replace in Project"

2 participants