feat(input): double-click selects the word under the cursor#59
Merged
Conversation
A left double-click (within ~400 ms and ~4 px of the previous press) selects the whole word under the pointer via a new motion::word_bounds helper, copies it to the clipboard, and returns to Insert mode — consistent with drag-selection. Word boundaries reuse the existing is_word logic (alphanumerics and underscore).
Double-click now leaves the selected word highlighted in anchored Visual mode (in addition to copying it) so the user can see what was picked, instead of silently returning to Insert with no visible feedback. A blank cell selects nothing; Esc or a click returns to Insert.
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.
What it does
A left double-click selects the word under the pointer, leaves it highlighted in anchored Visual mode (so you can see exactly what was picked), and copies it to the clipboard.
Escor a click returns to Insert.A double-click is registered when the second press happens within ~400 ms and less than ~4 px of the previous one. Word boundaries reuse the existing
is_wordlogic (alphanumerics and_). Double-clicking a blank cell selects nothing.Changes
src/input/motion.rs: newword_boundshelper (+ 4 tests).src/input/mouse_ops.rs: newselect_word_atmethod — sets anchored Visual selection over the word and copies it; empty/blank cells select nothing.src/app_event.rs:is_double_click+ wiring inhandle_selection_click.src/app_state.rs: new fieldlast_click: Option<(Instant, f64, f64)>.CHANGELOG.md.How to test manually
cargo run.echo hola-mundo foo_bar baz.foo_bar→ the whole word stays highlighted (_included) and is copied to the clipboard.Ctrl+Shift+Vor middle-click) at the prompt →foo_barappears.Esc(or click elsewhere) → the highlight clears and you are back in Insert.Tests
cargo test— full suite green.word_boundscovered by 4 tests (word_bounds_spans_whole_word_from_middle,_spans_first_word_from_edge,_on_space_selects_single_cell,_treats_underscore_as_word). The timing detection (is_double_click) and the on-screen highlight are validated manually (they depend on realwinit/rendering).