From 297fb013cb18bcceb15366c7877880a5ce0299e2 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 20 Apr 2019 19:57:43 +0200 Subject: [PATCH] wrapping: trim any trailing blanks when cursor goes to next line When typing a space causes both the succeeding word and the cursor to be pushed to the next line, then this space (and any contiguous ones) does need to be snipped (when --trimblanks is in effect). This fixes https://savannah.gnu.org/bugs/?56180. Bug existed since version 2.9.3, commit 91073be4. --- src/text.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/text.c b/src/text.c index fa1bb32a..e5d9ee7d 100644 --- a/src/text.c +++ b/src/text.c @@ -1505,7 +1505,8 @@ bool do_wrap(void) size_t tail_x = move_mbleft(line->data, wrap_loc); size_t typed_x = move_mbleft(line->data, cursor_x); - while (tail_x != typed_x && is_blank_mbchar(line->data + tail_x)) { + while ((tail_x != typed_x || cursor_x >= wrap_loc) && + is_blank_mbchar(line->data + tail_x)) { openfile->current_x = tail_x; do_delete(); tail_x = move_mbleft(line->data, tail_x);