From 7c30d1fa699fd4acafb0e543b5b5d3ca783acaa5 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 22 Feb 2019 14:09:17 +0100 Subject: [PATCH] display: account for zero-width characters when reserving space for '>' That is: keep nibbling off characters until a character is eaten that takes up at least one column. This fixes https://savannah.gnu.org/bugs/?55759. Reported-by: David Lawrence Ramsey Bug existed since version 2.8.0, commit 5283acdc. --- src/winio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/winio.c b/src/winio.c index 18ae548e..d550085b 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1990,7 +1990,9 @@ char *display_string(const char *buf, size_t column, size_t span, bool isdata) /* If there is more text than can be shown, make room for the ">". */ if ((*buf != '\0' || column > beyond) && (currmenu != MMAIN || (isdata && !ISSET(SOFTWRAP)))) { - index = move_mbleft(converted, index); + do { + index = move_mbleft(converted, index); + } while (mbwidth(converted + index) == 0); #ifdef ENABLE_UTF8 /* Display the left half of a two-column character as '['. */