From 3c2b5809788bdec41e24bb1c0133621ee8fa52ff Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Tue, 27 Jun 2017 16:26:05 -0500 Subject: [PATCH] softwrap: don't break text exactly at the screen edge This should eliminate all cases where the newline is pushed off the edge of the screen in non-atblanks softwrap mode. Also, it allows the use of the last column of the screen in atblanks softwrap mode. --- src/winio.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/winio.c b/src/winio.c index 4a60539..76d7eb9 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2993,17 +2993,12 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge, while (*text != '\0' && column < leftedge) text += parse_mbchar(text, NULL, &column); - /* Use a full screen row for text, or, if we're softwrapping at blanks, use - * a full screen row less one column for text and reserve the last column - * for blanks. The latter case is to ensure that we have enough room for - * blanks exactly on the last column of the screen. */ - if (ISSET(AT_BLANKS) && editwincols > 2) - goal_column = column + (editwincols - 1); - else - goal_column = column + editwincols; + /* Use a full screen row for text. */ + goal_column = column + editwincols; while (*text != '\0' && column <= goal_column) { - if (ISSET(AT_BLANKS) && editwincols > 2 && is_blank_mbchar(text)) { + /* Don't break the text at a blank exactly on the screen edge. */ + if (ISSET(AT_BLANKS) && is_blank_mbchar(text) && column < goal_column) { found_blank = TRUE; lastblank_index = index; lastblank_column = column; @@ -3018,7 +3013,9 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge, /* If the text displays within goal_column, we've reached the end of the * line, and we're done. */ if (column <= goal_column) { - *end_of_line = TRUE; + /* Don't break the text exactly on the screen edge. */ + if (column < goal_column) + *end_of_line = TRUE; return column; } -- 2.9.0