Skip to content

feat(mouse): Shift+Click extends the selection#76

Open
roramirez wants to merge 1 commit into
mainfrom
feat/shift-click-extend-selection
Open

feat(mouse): Shift+Click extends the selection#76
roramirez wants to merge 1 commit into
mainfrom
feat/shift-click-extend-selection

Conversation

@roramirez

Copy link
Copy Markdown
Owner

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: add extend_mouse_selection (resolves the clicked pane + cell, extends the current Visual selection, sets mouse_selecting = true) and a pure, testable extend_visual_mode helper that computes the new mode.
  • src/app_event.rs: in handle_selection_click's Pressed branch, read Shift via self.modifiers.state().shift_key(); if held, call extend_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 returning None for a fresh start.
  • CHANGELOG.md: add entry under [Unreleased] / Added.

How to test

  • cargo test — all pass, including the three new mouse_ops_test cases.
  • Manually: make a Visual selection with the mouse (or v in 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.

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.
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.

1 participant