From 00b639118e32c7e65a402ddf70a57d0238b5abe1 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Tue, 2 Mar 2021 17:38:16 -0500 Subject: fix restore session if no active buffer on close also more command selector --- buffer.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'buffer.c') diff --git a/buffer.c b/buffer.c index 28ec364..b016d9e 100644 --- a/buffer.c +++ b/buffer.c @@ -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). -- cgit v1.2.3