From e5ccfb4ee98da03ac5423c0570a4da33ef85b975 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Thu, 31 Dec 2020 14:12:56 -0500 Subject: set ted err to buffer err --- buffer.c | 4 ++++ command.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/buffer.c b/buffer.c index c79a2df..1c41f92 100644 --- a/buffer.c +++ b/buffer.c @@ -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."); diff --git a/command.c b/command.c index 69ce9ee..5d1a4d4 100644 --- a/command.c +++ b/command.c @@ -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); + } } -- cgit v1.2.3