fix: emoji text wrapping crash in pi-tui

Fixed crash when rendering text containing emojis followed by long content.
The breakLongWord function was iterating over UTF-16 code units instead of
grapheme clusters, causing emojis (surrogate pairs) to be miscounted during
line wrapping. Now uses Intl.Segmenter to properly handle multi-codepoint
characters.
This commit is contained in:
Mario Zechner
2025-11-26 23:55:01 +01:00
parent 5b940c2686
commit e7c48e33a2
3 changed files with 48 additions and 8 deletions
+12
View File
@@ -0,0 +1,12 @@
↑21 ↓442 R12k W10k $0.048 3.7% claude-sonnet-4-5file:///opt/homebrew/lib/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-tui/dist/tui.js:174
throw new Error(`Rendered line ${i} exceeds terminal width\n\n${newLines[i]}`);
^
Error: Rendered line 160 exceeds terminal width
😂\n\n[2025-11-21T21-45-04-863Z_b85e1b94-c1f2-4592-8521-b36cb24f93e7.html](https:
at TUI.doRender (file:///opt/homebrew/lib/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-tui/dist/tui.js:174:23)
at file:///opt/homebrew/lib/node_modules/@mariozechner/pi-coding-agent/node_modules/@mariozechner/pi-tui/dist/tui.js:68:18
at process.processTicksAndRejections (node:internal/process/task_queues:85:11)
Node.js v23.4.0