From ef6ae187289dd58a3b03da8b991a8099616a763d Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Fri, 26 Feb 2021 13:05:54 -0500 Subject: fix bug where selection_pos was invalid --- buffer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buffer.c b/buffer.c index ca58772..54931ce 100644 --- a/buffer.c +++ b/buffer.c @@ -131,8 +131,11 @@ static void buffer_pos_validate(TextBuffer *buffer, BufferPos *p) { p->index = line_len; } +// validate the cursor and selection positions static void buffer_validate_cursor(TextBuffer *buffer) { buffer_pos_validate(buffer, &buffer->cursor_pos); + if (buffer->selection) + buffer_pos_validate(buffer, &buffer->selection_pos); } static bool buffer_pos_valid(TextBuffer *buffer, BufferPos p) { -- cgit v1.2.3