From 22927fa1d7c8041e71bcba78f12230814a8d006d Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Fri, 4 Aug 2023 14:39:05 +0100 Subject: [PATCH] Fix visual selection cursor in multibuffers --- crates/editor/src/element.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index bc6c2f0bb8..d2e7ab00d7 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -860,9 +860,15 @@ impl EditorElement { } else if cursor_row > 0 && cursor_position != layout.position_map.snapshot.max_point() { - cursor_row -= 1; - cursor_column = - layout.position_map.snapshot.line_len(cursor_row) as usize; + let new = layout.position_map.snapshot.clip_point( + DisplayPoint::new( + cursor_row - 1, + layout.position_map.snapshot.line_len(cursor_row), + ), + Bias::Left, + ); + cursor_row = new.row(); + cursor_column = new.column() as usize; } } dbg!(selection.head, cursor_row, cursor_column);