summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-03-02 17:38:16 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-03-02 17:38:16 -0500
commit00b639118e32c7e65a402ddf70a57d0238b5abe1 (patch)
tree2eb42a40dbcd68337842b75afaa092cb0e41f603 /buffer.c
parent64bfab15c19ef0e0055b7b80b315a872b8946ce4 (diff)
fix restore session if no active buffer on close
also more command selector
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c4
1 files changed, 4 insertions, 0 deletions
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).