From e8f69e40d1a51299b1fae4858d73bd524c163671 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 21 Apr 2019 10:06:56 +0200 Subject: [PATCH] wrapping: add a missing space only when the remainder will be prepended When automatic hard-wrapping causes some piece of a line to be pushed to the next line, then a separating space needs to be added at the tail of this piece only when this piece actually gets prepended. This fixes https://savannah.gnu.org/bugs/?56185. Bug existed since version 2.9.2, commit 29f7654a. --- src/text.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/text.c b/src/text.c index e5d9ee7d..9f07012f 100644 --- a/src/text.c +++ b/src/text.c @@ -1466,7 +1466,8 @@ bool do_wrap(void) /* We prepend the wrapped text to the next line, if the prepend_wrap * flag is set, there is a next line, and prepending would not make * the line too long. */ - if (prepend_wrap && line != openfile->filebot) { + if (prepend_wrap && line != openfile->filebot && + rest_length + strlen(line->next->data) <= wrap_at) { const char *tail = remainder + move_mbleft(remainder, rest_length); /* Go to the end of the line. */ @@ -1488,13 +1489,11 @@ bool do_wrap(void) #endif } - if (rest_length + strlen(line->next->data) <= wrap_at) { /* Delete the LF to join the two lines. */ do_delete(); /* Delete any leading blanks from the joined-on line. */ while (is_blank_mbchar(&line->data[openfile->current_x])) do_delete(); - } } /* Go to the wrap location. */