From 7f5d454b2d3c9c864e90d4378bd4e546a8dc0c27 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 11 Oct 2021 13:08:50 +0200 Subject: [PATCH] Fix creation of anchors for the inserted portion of an edit --- crates/buffer/src/lib.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/crates/buffer/src/lib.rs b/crates/buffer/src/lib.rs index 182eabcc12..64a1a944fd 100644 --- a/crates/buffer/src/lib.rs +++ b/crates/buffer/src/lib.rs @@ -1051,7 +1051,6 @@ impl Buffer { ) .collect::>(); for (new_row, suggestion) in new_edited_row_range.zip(suggestions) { - dbg!(&suggestion); let delta = if suggestion.indent { INDENT_SIZE } else { 0 }; let new_indentation = self.indent_column_for_line(suggestion.basis_row) + delta; if old_suggestions @@ -1067,10 +1066,9 @@ impl Buffer { let inserted_row_ranges = contiguous_ranges( inserted .to_point_ranges(self.content()) - .flat_map(|range| dbg!(range.start.row..range.end.row + 1)), + .flat_map(|range| range.start.row..range.end.row + 1), ) .collect::>(); - dbg!(&inserted_row_ranges); for inserted_row_range in inserted_row_ranges { let suggestions = self .content() @@ -1083,7 +1081,6 @@ impl Buffer { .collect::>(); for (row, suggestion) in inserted_row_range.zip(suggestions) { - dbg!(&suggestion); let delta = if suggestion.indent { INDENT_SIZE } else { 0 }; let new_indentation = self.indent_column_for_line(suggestion.basis_row) + delta; @@ -1485,15 +1482,10 @@ impl Buffer { if let Some((before_edit, edited)) = autoindent_request { let mut inserted = None; if let Some(first_newline_ix) = first_newline_ix { - inserted = Some( - self.content() - .anchor_range_set(edit.ranges.iter().map(|range| { - dbg!( - (range.start + first_newline_ix + 1, Bias::Left) - ..(range.start + new_text_len, Bias::Right) - ) - })), - ); + inserted = Some(self.content().anchor_range_set(ranges.iter().map(|range| { + (range.start + first_newline_ix + 1, Bias::Left) + ..(range.start + new_text_len, Bias::Right) + }))); } self.autoindent_requests.push_back(AutoindentRequest {