diff options
-rw-r--r-- | buffer.c | 4 | ||||
-rw-r--r-- | command.c | 4 |
2 files changed, 8 insertions, 0 deletions
@@ -60,6 +60,10 @@ char const *buffer_geterr(TextBuffer *buffer) { return buffer->error; } +void buffer_clearerr(TextBuffer *buffer) { + *buffer->error = '\0'; +} + // set the buffer's error to indicate that we're out of memory static void buffer_out_of_mem(TextBuffer *buffer) { buffer_seterr(buffer, "Out of memory."); @@ -118,4 +118,8 @@ void command_execute(Ted *ted, Command c, i64 argument) { buffer_redo(buffer, argument); break; } + if (buffer_haserr(buffer)) { + strncpy(ted->error, buffer_geterr(buffer), sizeof ted->error - 1); + buffer_clearerr(buffer); + } } |