diff options
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -308,6 +308,9 @@ bool buffer_indent_with_spaces(TextBuffer *buffer) { } String32 buffer_get_line(TextBuffer *buffer, u32 line_number) { + if (line_number >= buffer->nlines) { + return str32(NULL, 0); + } Line *line = &buffer->lines[line_number]; return (String32) { .str = line->str, .len = line->len @@ -1998,6 +2001,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) { |