Allow selecting all search matches in buffer

This commit is contained in:
Kirill Bulatov 2023-07-13 14:29:02 +03:00
parent bf9dfa3b51
commit 29cbeb39bd
10 changed files with 146 additions and 16 deletions

View file

@ -908,6 +908,21 @@ impl Terminal {
}
}
pub fn select_matches(&mut self, matches: Vec<RangeInclusive<Point>>) {
let matches_to_select = self
.matches
.iter()
.filter(|self_match| matches.contains(self_match))
.cloned()
.collect::<Vec<_>>();
for match_to_select in matches_to_select {
self.set_selection(Some((
make_selection(&match_to_select),
*match_to_select.end(),
)));
}
}
fn set_selection(&mut self, selection: Option<(Selection, Point)>) {
self.events
.push_back(InternalEvent::SetSelection(selection));