Skip to content

Commit

Permalink
terminal: Handle shift+click selection (#25143)
Browse files Browse the repository at this point in the history
Closes #16951

Handle the case where you click on the terminal while pressing Shift. 

Instead of setting a new selection head, we simply update the selection
to that point. This allows you to repeatedly extend the selection to new
points by pressing Shift while preserving the original selection head.

Preview:

Selection works in direct terminal, but doesn't on Vim like program,
which is expected.


https://github.com/user-attachments/assets/e46987d8-a9a3-495d-8dd9-98d461317a8d


Release Notes:

- Added ability to extend selection with Shift + click in the terminal.
  • Loading branch information
0xtimsb authored and osiewicz committed Feb 19, 2025
1 parent 4a73bbb commit cca8224
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/terminal/src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,12 @@ impl Terminal {
_ => None,
};

if selection_type == Some(SelectionType::Simple) && e.modifiers.shift {
self.events
.push_back(InternalEvent::UpdateSelection(position));
return;
}

let selection = selection_type
.map(|selection_type| Selection::new(selection_type, point, side));

Expand Down

0 comments on commit cca8224

Please sign in to comment.