Test undo/redo at editor layer, including selection restoration
This commit is contained in:
parent
44cd0be068
commit
cdbcbdfe6d
5 changed files with 325 additions and 180 deletions
|
@ -1,42 +0,0 @@
|
|||
use super::{Anchor, MultiBufferSnapshot};
|
||||
use std::ops::Sub;
|
||||
use text::{rope::TextDimension, Selection};
|
||||
|
||||
fn resolve_selection<'a, D>(
|
||||
selection: &'a Selection<Anchor>,
|
||||
snapshot: &'a MultiBufferSnapshot,
|
||||
) -> Selection<D>
|
||||
where
|
||||
D: TextDimension + Ord + Sub<D, Output = D>,
|
||||
{
|
||||
Selection {
|
||||
id: selection.id,
|
||||
start: selection.start.summary::<D>(snapshot),
|
||||
end: selection.end.summary::<D>(snapshot),
|
||||
reversed: selection.reversed,
|
||||
goal: selection.goal,
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_selections<'a, D>(
|
||||
selections: &'a [Selection<Anchor>],
|
||||
snapshot: &'a MultiBufferSnapshot,
|
||||
) -> impl 'a + Iterator<Item = Selection<D>>
|
||||
where
|
||||
D: TextDimension + Ord + Sub<D, Output = D>,
|
||||
{
|
||||
let mut summaries = snapshot
|
||||
.summaries_for_anchors::<D, _>(
|
||||
selections
|
||||
.iter()
|
||||
.flat_map(|selection| [&selection.start, &selection.end]),
|
||||
)
|
||||
.into_iter();
|
||||
selections.iter().map(move |selection| Selection {
|
||||
id: selection.id,
|
||||
start: summaries.next().unwrap(),
|
||||
end: summaries.next().unwrap(),
|
||||
reversed: selection.reversed,
|
||||
goal: selection.goal,
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue