feat(mouse): Shift+Click extends the selection#76
Open
roramirez wants to merge 1 commit into
Open
Conversation
A plain left-press starts a fresh selection. When Shift is held and an existing Visual selection is present, keep its anchor (start_*) and move the cursor (cur_*) to the clicked cell so the selection grows from the original anchor to the click point; a following drag extends further and release copies. With no prior selection it falls back to a fresh one.
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
A plain left-press starts a fresh selection. This adds Shift+Click: when Shift is held at press time and an existing Visual selection is present, the selection is extended instead of reset — the original anchor (
start_col/start_row) is kept and the cursor (cur_col/cur_row) jumps to the clicked cell, so the selection grows from the anchor to the click point. Dragging afterward continues to extend, and release copies. With no prior selection, it falls back to a normal fresh selection from the click.Changes
src/input/mouse_ops.rs: addextend_mouse_selection(resolves the clicked pane + cell, extends the current Visual selection, setsmouse_selecting = true) and a pure, testableextend_visual_modehelper that computes the new mode.src/app_event.rs: inhandle_selection_click's Pressed branch, read Shift viaself.modifiers.state().shift_key(); if held, callextend_mouse_selection, otherwise keep the existing double/single-click dispatch.src/input/mouse_ops_test.rs: new tests covering extend-from-anchored-Visual (anchor preserved, cursor moved), extend-from-unanchored-Visual, and no-selection returningNonefor a fresh start.CHANGELOG.md: add entry under[Unreleased] / Added.How to test
cargo test— all pass, including the three newmouse_ops_testcases.vin Normal mode), then Shift+Click elsewhere in the pane — the selection extends from the original anchor to the click point rather than resetting; dragging continues to extend and releasing copies. A plain click (no Shift) still starts a fresh selection, and double-click still selects a word.