Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Implement SelectionsCollection::select_anchor_ranges
Max Brunsfeldfc2251e7ed2f
diff --git a/crates/editor2/src/selections_collection.rs b/crates/editor2/src/selections_collection.rsindex bcf41f135ba..6542ace5fbe 100644--- a/crates/editor2/src/selections_collection.rs+++ b/crates/editor2/src/selections_collection.rs@@ -595,31 +595,32 @@ impl<'a> MutableSelectionsCollection<'a> {self.select(selections)}- pub fn select_anchor_ranges<I: IntoIterator<Item = Range<Anchor>>>(&mut self, ranges: I) {- todo!()- // let buffer = self.buffer.read(self.cx).snapshot(self.cx);- // let selections = ranges- // .into_iter()- // .map(|range| {- // let mut start = range.start;- // let mut end = range.end;- // let reversed = if start.cmp(&end, &buffer).is_gt() {- // mem::swap(&mut start, &mut end);- // true- // } else {- // false- // };- // Selection {- // id: post_inc(&mut self.collection.next_selection_id),- // start,- // end,- // reversed,- // goal: SelectionGoal::None,- // }- // })- // .collect::<Vec<_>>();-- // self.select_anchors(selections)+ pub fn select_anchor_ranges<I>(&mut self, ranges: I)+ where+ I: IntoIterator<Item = Range<Anchor>>,+ {+ let buffer = self.buffer.read(self.cx).snapshot(self.cx);+ let selections = ranges+ .into_iter()+ .map(|range| {+ let mut start = range.start;+ let mut end = range.end;+ let reversed = if start.cmp(&end, &buffer).is_gt() {+ mem::swap(&mut start, &mut end);+ true+ } else {+ false+ };+ Selection {+ id: post_inc(&mut self.collection.next_selection_id),+ start,+ end,+ reversed,+ goal: SelectionGoal::None,+ }+ })+ .collect::<Vec<_>>();+ self.select_anchors(selections)}pub fn new_selection_id(&mut self) -> usize {