From 921f8f222f00f0e3ba44a20f57b31710273a065e Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 28 Nov 2016 09:41:31 -0500 Subject: [PATCH] Append should append the text after the last line of the buffer if selection is null, inserting a newline if necessary --- libedit/view.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libedit/view.c b/libedit/view.c index 198d533..525fd5f 100644 --- a/libedit/view.c +++ b/libedit/view.c @@ -429,6 +429,10 @@ void view_append(View* view, char* str) { size_t end = buf_end(&(view->buffer)); if (view->selection.end != end) view->selection = (Sel){ .beg = end, .end = end }; + if (!num_selected(view->selection) && !buf_iseol(&(view->buffer), view->selection.end-1)) { + buf_ins(&(view->buffer), view->selection.end++, '\n'); + view->selection.beg++; + } view_putstr(view, str); view_selprev(view); } -- 2.52.0