From 504a97256bfedfc78b0d274195820ca9a5ef426a Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sun, 13 Aug 2017 11:15:08 -0500 Subject: [PATCH] softwrap: break before multi-column Unicode blanks when they overshoot In atblanks mode, if a softwrapped chunk ends with a double-width space character (say, Unicode 003000, Ideographic Space), and that would put half of the character past the edge of the screen, break before it. This fixes https://savannah.gnu.org/bugs/?51671. --- src/winio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/winio.c b/src/winio.c index 47ccb21f..a790f498 100644 --- a/src/winio.c +++ b/src/winio.c @@ -3054,13 +3054,12 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge, * the pointer back to the last blank, step beyond it, and we're done. */ if (found_blank) { text = text - index + lastblank_index; - parse_mbchar(text, NULL, &lastblank_column); + char_len = parse_mbchar(text, NULL, &lastblank_column); + text += char_len; - /* If we've now overshot the screen's edge, then break there. */ - if (lastblank_column > goal_column) - return goal_column; - - return lastblank_column; + /* If we haven't overshot the screen's edge, break after the blank. */ + if (lastblank_column <= goal_column) + return lastblank_column; } /* If a tab is split over two chunks, break at the screen's edge. */