From 000d571290008378ae64109f7dcb5947d452ef41 Mon Sep 17 00:00:00 2001 From: pommicket Date: Thu, 23 Mar 2023 12:36:24 -0400 Subject: fix scrolling to cursor when text is typed --- buffer.c | 5 +++++ main.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/buffer.c b/buffer.c index fadeb59..3f25142 100644 --- a/buffer.c +++ b/buffer.c @@ -1998,6 +1998,11 @@ void buffer_insert_text_at_cursor(TextBuffer *buffer, String32 str) { buffer_delete_selection(buffer); // delete any selected text BufferPos endpos = buffer_insert_text_at_pos(buffer, buffer->cursor_pos, str); buffer_cursor_move_to_pos(buffer, endpos); + if (str.len) { + // this actually isn't handled by the move above since buffer->cursor_pos + // should be moved to endpos anyways. might as well keep that there though + buffer_scroll_to_cursor(buffer); + } } void buffer_insert_char_at_cursor(TextBuffer *buffer, char32_t c) { diff --git a/main.c b/main.c index d3038f6..4f17e77 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,5 @@ /* @TODO: -- scroll to cursor when text is typed - some rust error locations arent detected? FUTURE FEATURES: - better undo chaining (dechain on backspace?) -- cgit v1.2.3