Skip to content

fix(tui): align slash autocomplete descriptions for CJK aliases - #1981

Open
Iwctwbh wants to merge 1 commit into
XiaomiMiMo:mainfrom
Iwctwbh:fix/tui-slash-autocomplete-cjk-alignment
Open

fix(tui): align slash autocomplete descriptions for CJK aliases#1981
Iwctwbh wants to merge 1 commit into
XiaomiMiMo:mainfrom
Iwctwbh:fix/tui-slash-autocomplete-cjk-alignment

Conversation

@Iwctwbh

@Iwctwbh Iwctwbh commented Jul 30, 2026

Copy link
Copy Markdown

Fixes #1979

TUI 输入 / 的补全弹窗中,中文技能别名行(/前端设计/深度研究 等)右侧描述列与英文行不对齐。

原因:commands memo 的填充用 String.length + padEnd(),按 code unit 而非终端列宽计算。中文占 2 列但按 1 列算,中文行渲染宽度超出填充宽度,右侧描述被顶出 2~6 列。

改动:改用 Bun.stringWidth 计算列宽后填充(同文件 extmark 偏移已在用这个宽度函数)。

Before / after(数字为各行描述起始列):

Before: 16 / 18 / 20 / 22 混杂
/help           |Show help
/前端设计           |前端设计技能

After: 统一为 16
/help           |Show help
/前端设计       |前端设计技能

验证:

  • bun run build:local 构建后在 TUI 输入 /,中英文行描述列已对齐
  • 全仓 tsgo --noEmit 0 errors;oxlint 无新增告警;autocomplete-detect 测试 25/25 通过
  • exactSubmitOption 与 fuzzysort 均对 display.trimEnd() 比较,填充宽度变化不影响命令匹配

The slash popup padded command names with String.length/padEnd, which
counts UTF-16 code units instead of terminal columns. Chinese skill
aliases (e.g. /前端设计) render two cells per character, so those rows
were wider than the padding budget and the right-hand description
column was jagged. Pad in display columns with Bun.stringWidth instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@yanyihan-xiaomi yanyihan-xiaomi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple and correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 斜杠命令补全弹窗:中文别名行右侧描述列未对齐

2 participants