Make SelectionsCollection::disjoint_anchor_ranges return an iterator (#22948)

This helps discourage unnecessary collection to Vec

Release Notes:

- N/A
This commit is contained in:
Michael Sloan authored and GitHub committed 2025-01-10 09:37:46 +00:00
1 parent 712e255ee0
commit 97584f3cab
4 files changed
+24 -31

No files matched your search

+6 -3
View File
@@ -185,9 +185,12 @@ pub fn register(editor: &mut Editor, cx: &mut ViewContext<Vim>) {
let previous_selections = vim
.update_editor(cx, |_, editor, cx| {
let selections = action
.restore_selection
.then(|| editor.selections.disjoint_anchor_ranges());
let selections = action.restore_selection.then(|| {
editor
.selections
.disjoint_anchor_ranges()
.collect::<Vec<_>>()
});
editor.change_selections(None, cx, |s| {
let end = Point::new(range.end.0, s.buffer().line_len(range.end));
s.select_ranges([end..Point::new(range.start.0, 0)]);