From ffcf493b3163b296b1b3dd64a156f265d17fc5aa Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Tue, 27 Jun 2017 09:03:06 -0500 Subject: [PATCH] softwrap: ensure that lines' final blanks are always accessible With atblanks set, lines are softwrapped just before the edge of the screen. Without atblanks set, lines are softwrapped *at* the edge of the screen, and the latter can make the line's final blank inaccessible, just as with atblanks set. Fix this problem by always softwrapping lines just before the edge of the screen, and adjusting things accordingly. --- src/winio.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/winio.c b/src/winio.c index 4a60539..24b7406 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2763,10 +2763,10 @@ int update_softwrapped_line(filestruct *fileptr) if (end_of_line) break; - /* If the line is softwrapped before its last column, add a ">" just - * after its softwrap breakpoint, unless we're softwrapping at blanks - * and not in the middle of a word. */ - if (!ISSET(AT_BLANKS) && to_col - from_col < editwincols) + /* If the line is softwrapped before its next-to-last column, add a ">" + * just after its softwrap breakpoint, unless we're softwrapping at + * blanks and not in the middle of a word. */ + if (!ISSET(AT_BLANKS) && to_col - from_col < editwincols - 1) mvwaddch(edit, row - 1, to_col - from_col, '>'); from_col = to_col; @@ -2993,11 +2993,10 @@ 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 + /* Use a full screen row less one column for text, and reserve the last + * column for blanks. This is to ensure that we have enough room for * blanks exactly on the last column of the screen. */ - if (ISSET(AT_BLANKS) && editwincols > 2) + if (editwincols > 2) goal_column = column + (editwincols - 1); else goal_column = column + editwincols; -- 2.9.0