Skip to content

Commit 590df0a

Browse files
committed
Fix overtyping wide characters.
Overtyping the first half of a wide character with the second half of a wide character results in display garbage. This is because the trailing dummy is not cleaned up. i.e. ATTR_WIDE, ATTR_WDUMMY, ATTR_WDUMMY Here is a short script for demonstrating the behavior: #!/bin/sh alias printf=/usr/bin/printf printf こんにちは!; sleep 2 printf '\x1b[5D'; sleep 2 printf へ; sleep 2 printf ' '; sleep 2 echo Reference: https://git.suckless.org/st/commit/65f1dc428315ae9d7f362e10c668557c1379e7af.html
1 parent 365126f commit 590df0a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

st.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,6 +2522,10 @@ tputc(Rune u)
25222522
if (width == 2) {
25232523
gp->mode |= ATTR_WIDE;
25242524
if (term.c.x+1 < term.col) {
2525+
if (gp[1].mode == ATTR_WIDE && term.c.x+2 < term.col) {
2526+
gp[2].u = ' ';
2527+
gp[2].mode &= ~ATTR_WDUMMY;
2528+
}
25252529
gp[1].u = '\0';
25262530
gp[1].mode = ATTR_WDUMMY;
25272531
}

0 commit comments

Comments
 (0)