Severity: MEDIUM
Status: ✅ FIXED
Files: src/char_width.zig:229-231
// src/char_width.zig:228-232
// Fast path: ASCII printable + Latin-1 Supplement
if (cp < 0x0300) {
if (cp < 0x20 or (cp >= 0x7F and cp <= 0xA0)) return 0;
return 1;
}
The upper bound should be 0x9F: the C1 control block is 0x80..0x9F.
0xA0 is U+00A0 NO-BREAK SPACE, which is printable and occupies one cell. Bug
#144 removed an unreachable duplicate C1 check and left this off-by-one in
place.
The consequence is not merely a wrong width report. Width 0 marks the codepoint
as a combining mark, so writeChar routes it to the combining path, where
char_width.combiningIndex(0xA0) returns 0 (it is not in the combining table)
and the character is dropped. Text that uses NBSP — common in pasted rich text,
HTML-derived content, and some printf output — loses those spaces entirely.
// src/char_width.zig — the Latin-1 fast path
if (cp < 0x20 or (cp >= 0x7F and cp <= 0x9F)) return 0;
The upper bound is now 0x9F, the end of the C1 control block, so U+00A0 is
classified as a printable width-1 space and reaches writeChar as a normal
character instead of being routed to the combining path and dropped.
charWidth: NO-BREAK SPACE is width 1, not zero-width — bug #514
(src/char_width.zig) asserts charWidth(0xA0) == 1 and pins the boundaries
either side (0x9F stays zero-width, 0xA1 stays width 1).
Verified with the full suite on Zig 0.16.0 and 0.17.0: 1047/1047 passing on both.
Bug #104 (Hangul Jamo misclassified) and bug #211 (over-broad emoji ranges) are the same class of width-table boundary error.