Merge pull request #660 from nick1udwig/hold-shift-and-click-to-add-to-selection

hold shift and click to add to selection
This commit is contained in:
Jeremy Soller 2025-12-30 14:27:41 -07:00 committed by GitHub
commit a43b5f7d44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1145,18 +1145,27 @@ where
} else {
TermSide::Right
};
let selection = match click_kind {
ClickKind::Single => {
Selection::new(SelectionType::Simple, location, side)
// Check if shift is pressed and there's an existing selection to extend
if state.modifiers.shift() {
let mut term = terminal.term.lock();
if let Some(ref mut selection) = term.selection {
selection.update(location, side);
} else {
term.selection =
Some(Selection::new(SelectionType::Simple, location, side));
}
ClickKind::Double => {
Selection::new(SelectionType::Semantic, location, side)
}
ClickKind::Triple => {
Selection::new(SelectionType::Lines, location, side)
}
};
{
} else {
let selection = match click_kind {
ClickKind::Single => {
Selection::new(SelectionType::Simple, location, side)
}
ClickKind::Double => {
Selection::new(SelectionType::Semantic, location, side)
}
ClickKind::Triple => {
Selection::new(SelectionType::Lines, location, side)
}
};
let mut term = terminal.term.lock();
term.selection = Some(selection);
}