mirror of
git://git.sv.gnu.org/nano.git
synced 2025-02-07 00:45:07 +03:00
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.
This commit is contained in:
parent
2148e857e5
commit
f47ef539db
14
src/winio.c
14
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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user