diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index e5aad0e7d1904ea516bd96d3f8a772257f4d6f8c..35a55bc512c518bded22b33339dfc449d384ee14 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3027,7 +3027,13 @@ impl Editor { self.transact(cx, |this, cx| { this.buffer.update(cx, |buffer, cx| { - buffer.edit(deletion_ranges.into_iter().map(|range| (range, "")), cx); + let empty_str: Arc = "".into(); + buffer.edit( + deletion_ranges + .into_iter() + .map(|range| (range, empty_str.clone())), + cx, + ); }); this.update_selections( this.local_selections::(cx), @@ -3089,7 +3095,13 @@ impl Editor { self.transact(cx, |this, cx| { let buffer = this.buffer.update(cx, |buffer, cx| { - buffer.edit(edit_ranges.into_iter().map(|range| (range, "")), cx); + let empty_str: Arc = "".into(); + buffer.edit( + edit_ranges + .into_iter() + .map(|range| (range, empty_str.clone())), + cx, + ); buffer.snapshot(cx) }); let new_selections = new_cursors @@ -3137,14 +3149,12 @@ impl Editor { .text_for_range(start..end) .chain(Some("\n")) .collect::(); - edits.push((start, text, rows.len() as u32)); + edits.push((start..start, text)); } self.transact(cx, |this, cx| { this.buffer.update(cx, |buffer, cx| { - for (point, text, _) in edits.into_iter().rev() { - buffer.edit([(point..point, text)], cx); - } + buffer.edit(edits, cx); }); this.request_autoscroll(Autoscroll::Fit, cx); @@ -4259,7 +4269,14 @@ impl Editor { if !edit_ranges.is_empty() { if all_selection_lines_are_comments { - buffer.edit(edit_ranges.iter().cloned().map(|range| (range, "")), cx); + let empty_str: Arc = "".into(); + buffer.edit( + edit_ranges + .iter() + .cloned() + .map(|range| (range, empty_str.clone())), + cx, + ); } else { let min_column = edit_ranges.iter().map(|r| r.start.column).min().unwrap(); diff --git a/crates/editor/src/multi_buffer.rs b/crates/editor/src/multi_buffer.rs index c08f7620160a9b4bc63a5d0914bc04675e0f721f..7ba9f248065f6b951eb531477452a8415993e683 100644 --- a/crates/editor/src/multi_buffer.rs +++ b/crates/editor/src/multi_buffer.rs @@ -377,6 +377,7 @@ impl MultiBuffer { let mut edits = edits.into_iter().peekable(); 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() @@ -399,7 +400,7 @@ impl MultiBuffer { } else if !range.is_empty() { deletions.push(( buffer.anchor_before(range.start)..buffer.anchor_before(range.end), - "", + empty_str.clone(), )); } }