Severity: LOW
Status: 🟢 FIXED
Files: src/thai.zig:96-105, src/char_width.zig:198-219
In src/thai.zig, cellHasMaiHanAkat checks whether a cell contains MAI HAN AKAT (U+0E31):
pub fn cellHasMaiHanAkat(cell: Cell) bool {
if (cell.char == 0x0E31) return true;
if (cell.comb1 != 0) {
if (cell.comb1 == 0x0E31 or char_width.combiningCodepoint(cell.comb1) == 0x0E31) return true;
}
if (cell.comb2 != 0) {
if (cell.comb2 == 0x0E31 or char_width.combiningCodepoint(cell.comb2) == 0x0E31) return true;
}
return false;
}
The fields Cell.comb1 and Cell.comb2 are defined as u13 (13 bits, range 0..8191). In the actual terminal parser and grid pipeline (src/screen.zig:808, 856), combining codepoints are converted to 1-based table indices using char_width.combiningIndex(cp):
prev_cell.comb1 = char_width.combiningIndex(cp);
All subsystems (rendering in src/server/render.zig, TTY output in src/tty/tty.zig, copy mode in src/mode_copy.zig, and libthai conversion in src/thai.zig:522) resolve combining marks via char_width.combiningCodepoint(cell.comb1).
Comparing cell.comb1 == 0x0E31 directly:
comb1 holds an index (~300), not the raw codepoint (0x0E31 = 3633).src/grid.zig that bypassed combiningIndex.src/thai.zig, simplify cellHasMaiHanAkat to consistently check only via char_width.combiningCodepoint:
pub fn cellHasMaiHanAkat(cell: Cell) bool {
if (cell.char == 0x0E31) return true;
if (cell.comb1 != 0 and char_width.combiningCodepoint(cell.comb1) == 0x0E31) return true;
if (cell.comb2 != 0 and char_width.combiningCodepoint(cell.comb2) == 0x0E31) return true;
return false;
}
char_width.combiningIndex(cp) instead of raw codepoint literals.src/thai.zig, simplified cellHasMaiHanAkat to check only via char_width.combiningCodepoint, eliminating the dead comb1 == 0x0E31 comparison against table indices.src/thai.zig to store combining marks using char_width.combiningIndex(...)./// line in isThaiFollowingVowel docstring to avoid Markdown text collapse.