fix: paste with Ctrl+V into Search & Replace fields (#1960)#1979
Open
sinelaw wants to merge 1 commit into
Open
fix: paste with Ctrl+V into Search & Replace fields (#1960)#1979sinelaw wants to merge 1 commit into
sinelaw wants to merge 1 commit into
Conversation
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.
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.
Fixes #1960.
Problem
The project Search & Replace panel (Command Palette → "Search and Replace in Project") runs the focused buffer in a
search-replace-listmode whose host-side text-input handler inapp/input.rsswallows 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:
app/input.rstext-input-mode handler — when a Ctrl/Alt-modified character key reaches the text-input bypass, resolve it against the Normal context first and let onlyAction::Pastethrough. Other normal bindings (Ctrl+O open-file, Ctrl+S save, …) stay blocked, so the search field is not promoted to a global command bar.app/input.rsAction::Pastehandler — route paste through the focused widget input before theediting_disabledguard, since the Search & Replace results buffer is a read-only virtual buffer and the existing guard would otherwise short-circuit.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 newpaste_into_focused_widgethelper. 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 ignoredcargo test -p fresh-editor --test e2e_tests paste— 63 pass / 2 ignoredcargo check --all-targets -p fresh-editor— cleancargo fmt --check— cleanGenerated by Claude Code