This commit is contained in:
Antonio Scandurra 2021-11-15 19:52:48 +01:00
parent 53872a6024
commit 763ab4d5f1

View file

@ -146,14 +146,16 @@ impl BlockMap {
new_transforms.push_tree(cursor.slice(&old_start, Bias::Left, &()), &()); new_transforms.push_tree(cursor.slice(&old_start, Bias::Left, &()), &());
} }
let overshoot = old_start.0 - cursor.start().0; let overshoot = Point::new(edit.new.start, 0) - new_transforms.summary().input;
if !overshoot.is_zero() { if !overshoot.is_zero() {
new_transforms.push(Transform::isomorphic(overshoot), &()); new_transforms.push(Transform::isomorphic(overshoot), &());
} }
let old_end = WrapPoint::new(edit.old.end, 0); let old_end = WrapPoint::new(edit.old.end, 0);
cursor.seek(&old_end, Bias::Left, &()); if old_end > *cursor.start() {
cursor.next(&()); cursor.seek(&old_end, Bias::Left, &());
cursor.next(&());
}
let start_anchor = buffer.anchor_before(Point::new(edit.new.start, 0)); let start_anchor = buffer.anchor_before(Point::new(edit.new.start, 0));
let start_block_ix = match self.blocks[last_block_ix..].binary_search_by(|probe| { let start_block_ix = match self.blocks[last_block_ix..].binary_search_by(|probe| {
@ -214,6 +216,9 @@ impl BlockMap {
} }
} }
if let Some(last_old_end) = last_old_end {
new_transforms.push(Transform::isomorphic(cursor.start() - last_old_end), &());
}
new_transforms.push_tree(cursor.suffix(&()), &()); new_transforms.push_tree(cursor.suffix(&()), &());
drop(cursor); drop(cursor);