fix(ink): 禁止 Unicode 制表符在 CJK 终端下渲染 — 自动映射为 ASCII(- | +)#2368
Closed
zzhan111 wants to merge 2 commits into
Closed
Conversation
Box-drawing characters (U+2500–U+257F) are East Asian Ambiguous Width and render as double-width cells in CJK terminals (zh/ja/ko locale, Windows code page 936/932/949). Yoga-layout assumes single-width, causing horizontal overflow, status-bar fragmentation, and overlapping dialogs. Changes: - render-border.ts: add isCJKLocale() detection and cjkAsciiEq mapping table; remap all border glyphs to ASCII (- | +) when on a CJK system - render-border.ts: rewrite embedTextInBorder to use stringWidth() throughout instead of mixing JS .length with visual widths - stringWidth.ts: make eastAsianWidth() and Bun string-width respect ambiguous-as-wide when the system locale is CJK Fixes: separator overflow, status bar misalignment, dialog overlap.
Characters like ✓ (U+2713), ⚡ (U+26A1), ⛁ (U+26C1), ⚑ (U+2691) fall in the 0x2600-0x27bf block (Miscellaneous Symbols). They are matched by the emoji regex but rendered single-cell in terminal emulators and CJK code-page consoles — unlike true emoji presentation glyphs that occupy 2 cells. getEmojiWidth now returns 1 for this range, preventing yoga-layout from overcounting the status-bar and toast line widths.
Collaborator
|
🙏 真诚感谢您的贡献! 感谢您为 DeepSeek-Reasonix v1 分支提交的 PR。这些改进体现了您对项目的认真态度和专业技术能力。 关于 v1 分支的说明: v1 (0.x, TypeScript) 版本目前已 完全停止维护。项目已全面迁移至 v2 (Go rewrite, 由于 v1 已不再接受代码变更,此 PR 将被关闭。 我们非常欢迎您将这些修复贡献到 v2 分支! 如果您有兴趣,可以:
再次感谢您的时间和精力!您的贡献对开源社区非常有价值。❤️
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
在 zh-CN/ja-JP/ko-KR locale(Windows 代码页 936/932/949)下,Unicode 制表符(U+2500–U+257F:─│┌┐└┘ 等)被终端当作 2 列宽渲染,但 Reasonix 的 yoga-layout 按 1 列计算,导致:
Closes #2366
改动
packages/ink/src/render-border.tspackages/ink/src/stringWidth.ts测试
在 Windows cmd.exe(chcp 936)下验证: