fix jump to nearest delta

This commit is contained in:
Dongdong Zhou 2022-03-03 12:25:02 +00:00
parent 74f431c1de
commit 963456830c
1 changed files with 11 additions and 0 deletions

View File

@ -980,6 +980,17 @@ fn jump_to_nearest_delta(&mut self, delta: &RopeDelta) {
let offset = transformer.transform(offset, false);
let (ins, del) = delta.clone().factor();
let ins = ins.transform_shrink(&del);
for el in ins.els.iter() {
match el {
xi_rope::DeltaElement::Copy(b, e) => {
// if b == e, ins.inserted_subset() will panic
if b == e {
return;
}
}
xi_rope::DeltaElement::Insert(_) => {}
}
}
let mut positions = ins
.inserted_subset()
.complement_iter()