From 1845205499f07e42d1050c182481d627d611a135 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 27 Sep 2024 13:27:28 -0700 Subject: [PATCH] Fix go-to-line test --- crates/editor/src/editor.rs | 4 +++- crates/go_to_line/src/go_to_line.rs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 0e245c0a3ca0a..b604f388debd5 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -11644,7 +11644,9 @@ impl Editor { let start = highlight.range.start.to_display_point(&snapshot); let end = highlight.range.end.to_display_point(&snapshot); let start_row = start.row().0; - let end_row = if end.column() == 0 { + let end_row = if highlight.range.end.text_anchor != text::Anchor::MAX + && end.column() == 0 + { end.row().0.saturating_sub(1) } else { end.row().0 diff --git a/crates/go_to_line/src/go_to_line.rs b/crates/go_to_line/src/go_to_line.rs index 2fc3b3bee6658..0e9482b759414 100644 --- a/crates/go_to_line/src/go_to_line.rs +++ b/crates/go_to_line/src/go_to_line.rs @@ -117,7 +117,7 @@ impl GoToLine { self.active_editor.update(cx, |active_editor, cx| { let snapshot = active_editor.snapshot(cx).display_snapshot; let start = snapshot.buffer_snapshot.clip_point(point, Bias::Left); - let end = point + Point::new(1, 0); + let end = start + Point::new(1, 0); let start = snapshot.buffer_snapshot.anchor_before(start); let end = snapshot.buffer_snapshot.anchor_after(end); active_editor.clear_row_highlights::(); @@ -246,13 +246,13 @@ mod tests { field_1: i32, // display line 3 field_2: i32, // display line 4 } // display line 5 - // display line 7 - struct Another { // display line 8 - field_1: i32, // display line 9 - field_2: i32, // display line 10 - field_3: i32, // display line 11 - field_4: i32, // display line 12 - } // display line 13 + // display line 6 + struct Another { // display line 7 + field_1: i32, // display line 8 + field_2: i32, // display line 9 + field_3: i32, // display line 10 + field_4: i32, // display line 11 + } // display line 12 "} }), )