From 14fcc26e73386f32c2320ecebf74fcc321ed31ea Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 23 Jul 2021 16:20:27 +0200 Subject: [PATCH] Don't insert empty isomorphic transforms when interpolating Co-Authored-By: Nathan Sobo --- zed/src/editor/display_map/wrap_map.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zed/src/editor/display_map/wrap_map.rs b/zed/src/editor/display_map/wrap_map.rs index d7b97513e8d29e538e3730f3c8fbd52d98ab969c..daff0a3de9d0295891507b4ba2c4888cf9077cc3 100644 --- a/zed/src/editor/display_map/wrap_map.rs +++ b/zed/src/editor/display_map/wrap_map.rs @@ -277,9 +277,11 @@ impl Snapshot { new_transforms.push_or_extend(Transform::isomorphic(summary)); } - new_transforms.push_or_extend(Transform::isomorphic( - new_tab_snapshot.text_summary_for_range(edit.new_lines.clone()), - )); + if !edit.new_lines.is_empty() { + new_transforms.push_or_extend(Transform::isomorphic( + new_tab_snapshot.text_summary_for_range(edit.new_lines.clone()), + )); + } old_cursor.seek_forward(&edit.old_lines.end, Bias::Right, &()); if let Some(next_edit) = edits.peek() { @@ -647,6 +649,9 @@ impl<'a> Iterator for BufferRows<'a> { impl Transform { fn isomorphic(summary: TextSummary) -> Self { + #[cfg(test)] + assert!(!summary.lines.is_zero()); + Self { summary: TransformSummary { input: summary.clone(),