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 2025-01-10 02:37:46 -07:00 committed by GitHub
parent 690ad29ba9
commit 1b44398967
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 31 deletions

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)]);