diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-03-02 17:38:16 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-03-02 17:38:16 -0500 |
commit | 00b639118e32c7e65a402ddf70a57d0238b5abe1 (patch) | |
tree | 2eb42a40dbcd68337842b75afaa092cb0e41f603 /buffer.c | |
parent | 64bfab15c19ef0e0055b7b80b315a872b8946ce4 (diff) |
fix restore session if no active buffer on close
also more command selector
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -1249,6 +1249,8 @@ static Status buffer_insert_lines(TextBuffer *buffer, u32 where, u32 number) { // inserts the given text, returning the position of the end of the text BufferPos buffer_insert_text_at_pos(TextBuffer *buffer, BufferPos pos, String32 str) { + buffer_pos_validate(buffer, &pos); + if (buffer->view_only) return pos; if (str.len > U32_MAX) { @@ -1480,6 +1482,8 @@ void buffer_delete_chars_at_pos(TextBuffer *buffer, BufferPos pos, i64 nchars_) if (nchars_ > U32_MAX) nchars_ = U32_MAX; u32 nchars = (u32)nchars_; + buffer_pos_validate(buffer, &pos); + // Correct nchars in case it goes past the end of the file. // Why do we need to correct it? // When generating undo events, we allocate nchars characters of memory (see buffer_edit below). |