diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 440a5d53469f119c007cdf32e8b6a148121daaa5..9efbd6accbd5cfc887b47836c34bf81b0d8cb8c2 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -9801,7 +9801,17 @@ mod tests { #[gpui::test] fn test_editing_overlapping_excerpts(cx: &mut gpui::MutableAppContext) { cx.set_global(Settings::test(cx)); - let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx)); + let buffer = cx.add_model(|cx| { + Buffer::new( + 0, + indoc! {" + aaaa + bbbb + cccc"}, + cx, + ) + }); + let multibuffer = cx.add_model(|cx| { let mut multibuffer = MultiBuffer::new(0); multibuffer.push_excerpts( diff --git a/crates/editor/src/multi_buffer.rs b/crates/editor/src/multi_buffer.rs index 7ba9f248065f6b951eb531477452a8415993e683..2f41ce09a01f52d41a4628ed5a9b7d1d00b4738d 100644 --- a/crates/editor/src/multi_buffer.rs +++ b/crates/editor/src/multi_buffer.rs @@ -378,13 +378,11 @@ impl MultiBuffer { let mut insertions = Vec::new(); let mut deletions = Vec::new(); let empty_str: Arc = "".into(); - while let Some((mut range, mut new_text, mut is_insertion)) = edits.next() { - while let Some((next_range, next_new_text, next_is_insertion)) = - edits.peek() - { + while let Some((mut range, new_text, mut is_insertion)) = edits.next() { + while let Some((next_range, _, next_is_insertion)) = edits.peek() { if range.end >= next_range.start { range.end = cmp::max(next_range.end, range.end); - new_text = format!("{new_text}{next_new_text}").into(); + is_insertion |= *next_is_insertion; edits.next(); } else { @@ -395,7 +393,7 @@ impl MultiBuffer { if is_insertion { insertions.push(( buffer.anchor_before(range.start)..buffer.anchor_before(range.end), - new_text, + new_text.clone(), )); } else if !range.is_empty() { deletions.push((