commit f47ef539db50864bbd3b50a40987a30d834a68bd
parent 2148e857e586df78e85959bb660be52985ca42ee
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 15 Jan 2020 17:28:14 +0100
display: skip zero-width characters on a Linux console, to avoid a mess
This is a workaround for the VT not being able to handle zero-width
characters properly, displaying them mistakenly as visible characters.
This avoids https://savannah.gnu.org/bugs/?52954.
The problem has existed since forever, but has become noticeable
since the capability for line numbers was added in version 2.7.1.
Diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -1939,13 +1939,21 @@ char *display_string(const char *buf, size_t column, size_t span,
continue;
}
+ /* Determine whether the character takes zero, one, or two columns. */
+ charwidth = wcwidth(wc);
+
+#ifdef __linux__
+ /* On a Linux console, skip zero-width characters, as it would show
+ * them WITH a width, thus messing up the display. See bug #52954. */
+ if (on_a_vt && charwidth == 0) {
+ buf += charlength;
+ continue;
+ }
+#endif
/* For any valid character, just copy its bytes. */
for (; charlength > 0; charlength--)
converted[index++] = *(buf++);
- /* Determine whether the character occupies one or two columns. */
- charwidth = wcwidth(wc);
-
/* If the codepoint is unassigned, assume a width of one. */
column += (charwidth < 0 ? 1 : charwidth);