use more predictable rules for selecting which bracket to jump to and where

This commit is contained in:
Kay Simmons 2023-02-15 14:04:16 -08:00
parent 5041300b52
commit 0ba051a754
15 changed files with 457 additions and 217 deletions

View file

@ -659,6 +659,31 @@ impl<'a> MutableSelectionsCollection<'a> {
}
}
pub fn move_offsets_with(
&mut self,
mut move_selection: impl FnMut(&MultiBufferSnapshot, &mut Selection<usize>),
) {
let mut changed = false;
let snapshot = self.buffer().clone();
let selections = self
.all::<usize>(self.cx)
.into_iter()
.map(|selection| {
let mut moved_selection = selection.clone();
move_selection(&snapshot, &mut moved_selection);
if selection != moved_selection {
changed = true;
}
moved_selection
})
.collect();
drop(snapshot);
if changed {
self.select(selections)
}
}
pub fn move_heads_with(
&mut self,
mut update_head: impl FnMut(