Severity: MEDIUM
Status: 🟢 FIXED
Files: src/thai.zig:152-156, src/grid.zig:560-566, docs/text_reflow.md:58
In src/thai.zig, findThaiClusterEnd groups Thai graphemes into indivisible visual clusters so that reflow never wraps across intra-cluster boundaries:
// Check for an optional following vowel
if (isThaiFollowingVowel(line[pos].char)) {
pos += 1;
}
The function uses an if check, consuming at most one following vowel. However, standard Thai orthography features compound vowels that use two consecutive following vowels. In particular, the เ-าะ pattern (e.g., เกาะ, เฉพาะ, เบาะ, เหมาะ) consists of:
เ (U+0E40, SARA E — leading vowel)ก (U+0E01, KO KAI)า (U+0E32, SARA AA — following vowel)ะ (U+0E30, SARA A — following vowel)เ is consumed (pos = 1).ก is consumed (pos = 2).า is consumed by if (isThaiFollowingVowel(...)) (pos = 3).ะ because U+0E30 is a following vowel, not right-attaching (U+0E2F / U+0E46).[เ, ก, า]).ะ). Since isThaiBase(0x0E30) returns false, line 140 returns start + 1 = 4.ะ becomes an orphaned 1-cell pseudo-cluster.During pane resize and reflow in src/grid.zig, wrap boundaries are calculated across cluster endings. Because ะ is in its own cluster, rewrap can legally break lines between เกา and ะ (wrapping as เกา|ะ).
src/thai.zig, replace the single if check with a while loop to consume all consecutive following vowels:
// Consume consecutive following vowels (e.g. าะ in เ-าะ)
while (pos < line.len and isThaiFollowingVowel(line[pos].char)) {
pos += 1;
}
This is safe against over-consumption because following vowels (isThaiFollowingVowel) cannot validly start a syllable cluster anyway.
findThaiClusterEnd and the cluster syntax in docs/text_reflow.md:58 from [Following Vowel]? to [Following Vowels]*.src/thai.zig verifying that a 4-cell word such as เกาะ forms a single cluster of length 4.src/thai.zig, updated findThaiClusterEnd to consume consecutive following vowels in a while (pos < line.len and isThaiFollowingVowel(line[pos].char)) loop.findThaiClusterEnd docstring to document [following vowels] plural.src/thai.zig for multi-vowel syllables (เกาะ → 4 cells, and เกาะๆ with right-attaching marks → 5 cells).