Move selection helpers to SelectionCollection, add update_anchor_selections, add a number of invariant preserving mutation functions to the MutableSelectionCollection

This commit is contained in:
Keith Simmons 2022-05-05 21:09:26 -07:00
parent 61b4a4202f
commit c9dcfff607
22 changed files with 1891 additions and 1467 deletions

View file

@ -128,7 +128,9 @@ impl<'a> VimTestContext<'a> {
let (unmarked_text, markers) = marked_text(&text);
editor.set_text(unmarked_text, cx);
let cursor_offset = markers[0];
editor.replace_selections_with(cx, |map| cursor_offset.to_display_point(map));
editor.change_selections(true, cx, |s| {
s.replace_cursors_with(|map| vec![cursor_offset.to_display_point(map)])
});
})
}
@ -197,7 +199,8 @@ impl<'a> VimTestContext<'a> {
let (empty_selections, reverse_selections, forward_selections) =
self.editor.read_with(self.cx, |editor, cx| {
let (empty_selections, non_empty_selections): (Vec<_>, Vec<_>) = editor
.local_selections::<usize>(cx)
.selections
.interleaved::<usize>(&editor.buffer().read(cx).read(cx))
.into_iter()
.partition_map(|selection| {
if selection.is_empty() {