WIP
This commit is contained in:
parent
8432daef6a
commit
f5c775fcd1
2 changed files with 44 additions and 29 deletions
|
@ -3049,35 +3049,50 @@ impl Editor {
|
||||||
where
|
where
|
||||||
D: 'a + TextDimension + Ord + Sub<D, Output = D>,
|
D: 'a + TextDimension + Ord + Sub<D, Output = D>,
|
||||||
{
|
{
|
||||||
// let buffer = self.buffer.read(cx).snapshot(cx);
|
let buffer = self.buffer.read(cx).snapshot(cx);
|
||||||
// let mut selections = self.selection_set(cx).selections::<D>(&buffer).peekable();
|
|
||||||
// let mut pending_selection = self.pending_selection(cx);
|
|
||||||
|
|
||||||
// iter::from_fn(move || {
|
let mut summaries = buffer
|
||||||
// if let Some(pending) = pending_selection.as_mut() {
|
.summaries_for_anchors::<D, _>(self.selections.iter().flat_map(|s| [&s.start, &s.end]))
|
||||||
// while let Some(next_selection) = selections.peek() {
|
.into_iter();
|
||||||
// if pending.start <= next_selection.end && pending.end >= next_selection.start {
|
|
||||||
// let next_selection = selections.next().unwrap();
|
|
||||||
// if next_selection.start < pending.start {
|
|
||||||
// pending.start = next_selection.start;
|
|
||||||
// }
|
|
||||||
// if next_selection.end > pending.end {
|
|
||||||
// pending.end = next_selection.end;
|
|
||||||
// }
|
|
||||||
// } else if next_selection.end < pending.start {
|
|
||||||
// return selections.next();
|
|
||||||
// } else {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pending_selection.take()
|
let mut selections = self
|
||||||
// } else {
|
.selections
|
||||||
// selections.next()
|
.iter()
|
||||||
// }
|
.map(|s| Selection {
|
||||||
// })
|
id: s.id,
|
||||||
// .collect()
|
start: summaries.next().unwrap(),
|
||||||
todo!()
|
end: summaries.next().unwrap(),
|
||||||
|
reversed: s.reversed,
|
||||||
|
goal: s.goal,
|
||||||
|
})
|
||||||
|
.peekable();
|
||||||
|
|
||||||
|
let mut pending_selection = self.pending_selection::<D>(&buffer, cx);
|
||||||
|
|
||||||
|
iter::from_fn(move || {
|
||||||
|
if let Some(pending) = pending_selection.as_mut() {
|
||||||
|
while let Some(next_selection) = selections.peek() {
|
||||||
|
if pending.start <= next_selection.end && pending.end >= next_selection.start {
|
||||||
|
let next_selection = selections.next().unwrap();
|
||||||
|
if next_selection.start < pending.start {
|
||||||
|
pending.start = next_selection.start;
|
||||||
|
}
|
||||||
|
if next_selection.end > pending.end {
|
||||||
|
pending.end = next_selection.end;
|
||||||
|
}
|
||||||
|
} else if next_selection.end < pending.start {
|
||||||
|
return selections.next();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pending_selection.take()
|
||||||
|
} else {
|
||||||
|
selections.next()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pending_selection<D: TextDimension + Ord + Sub<D, Output = D>>(
|
fn pending_selection<D: TextDimension + Ord + Sub<D, Output = D>>(
|
||||||
|
|
|
@ -777,7 +777,7 @@ impl MultiBufferSnapshot {
|
||||||
summary
|
summary
|
||||||
}
|
}
|
||||||
|
|
||||||
fn summary_for_anchor<D>(&self, anchor: &Anchor) -> D
|
pub fn summary_for_anchor<D>(&self, anchor: &Anchor) -> D
|
||||||
where
|
where
|
||||||
D: TextDimension + Ord + Sub<D, Output = D>,
|
D: TextDimension + Ord + Sub<D, Output = D>,
|
||||||
{
|
{
|
||||||
|
@ -798,7 +798,7 @@ impl MultiBufferSnapshot {
|
||||||
D::from_text_summary(&cursor.start().text)
|
D::from_text_summary(&cursor.start().text)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn summaries_for_anchors<'a, D, I>(&'a self, anchors: I) -> Vec<D>
|
pub fn summaries_for_anchors<'a, D, I>(&'a self, anchors: I) -> Vec<D>
|
||||||
where
|
where
|
||||||
D: TextDimension + Ord + Sub<D, Output = D>,
|
D: TextDimension + Ord + Sub<D, Output = D>,
|
||||||
I: 'a + IntoIterator<Item = &'a Anchor>,
|
I: 'a + IntoIterator<Item = &'a Anchor>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue