mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 06:05:19 +00:00
Implement SelectionsCollection::select_anchor_ranges
This commit is contained in:
parent
0d31722589
commit
fc2251e7ed
1 changed files with 26 additions and 25 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue