From 763ab4d5f135287a953165793035fd5cc884b938 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 15 Nov 2021 19:52:48 +0100 Subject: [PATCH] WIP --- crates/editor/src/display_map/block_map.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 12bf8cfb34..8cc7f85967 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -146,14 +146,16 @@ impl BlockMap { 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() { new_transforms.push(Transform::isomorphic(overshoot), &()); } let old_end = WrapPoint::new(edit.old.end, 0); - cursor.seek(&old_end, Bias::Left, &()); - cursor.next(&()); + if old_end > *cursor.start() { + cursor.seek(&old_end, Bias::Left, &()); + cursor.next(&()); + } 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| { @@ -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(&()), &()); drop(cursor);