From b5c3bde42a72007fad423056c89afb2181a022cc Mon Sep 17 00:00:00 2001 From: Thomas Churchman Date: Thu, 28 Nov 2024 16:07:15 +0100 Subject: [PATCH] Fix off-by-one (selecting last probably should have upstream affinity) --- masonry/src/text/editor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/masonry/src/text/editor.rs b/masonry/src/text/editor.rs index 51ccda73c..f348740ea 100644 --- a/masonry/src/text/editor.rs +++ b/masonry/src/text/editor.rs @@ -653,7 +653,7 @@ where fn cursor_at(&self, index: usize) -> Cursor { // TODO: Do we need to be non-dirty? // FIXME: `Selection` should make this easier - if index > self.buffer.len() { + if index >= self.buffer.len() { Cursor::from_byte_index(&self.layout, self.buffer.len(), Affinity::Upstream) } else { Cursor::from_byte_index(&self.layout, index, Affinity::Downstream)