Skip to content

fix: cluster base + U+FE0F as a width-2 emoji glyph - #84

Draft
natemoo-re wants to merge 3 commits into
mainfrom
nm/repro/vs16-emoji-width
Draft

fix: cluster base + U+FE0F as a width-2 emoji glyph#84
natemoo-re wants to merge 3 commits into
mainfrom
nm/repro/vs16-emoji-width

Conversation

@natemoo-re

@natemoo-re natemoo-re commented Jun 5, 2026

Copy link
Copy Markdown
Member
  • Fixes 🐛 VS16 (U+FE0F) emoji measured at the wrong width #81
  • measure() and render_text() summed per-codepoint widths with no grapheme awareness, so a base codepoint followed by U+FE0F (variation selector-16) measured as base-width + 0 instead of one width-2 emoji cluster
  • Both loops gain a one-codepoint lookahead: when the next codepoint is U+FE0F, the pair is treated as a single width-2 cluster — only the base glyph is placed and both codepoints are consumed; the wcwidth table is untouched
  • The repro's third assertion (a bordered fit() box rendering ┌──────┐) was rescoped to the render path. It depended on a separate, pre-existing bug: a fit() box's border does not reserve layout space, so even 6-wide ASCII content renders ┌────┐. That behavior is independent of this fix and tracked separately (it conflicts with the committed border-overlay model and its tests)
  • The regression lives in test/width.test.ts under describe("emoji width") rather than a standalone file. fix: collapse orphaned wide-char lead on trailing-column overlay #86 also adds to test/width.test.ts (describe("wide characters")), so whichever merges second needs a trivial rebase to keep both describes
  • Test plan: deno test green (8 passed / 148 steps); deno lint + deno fmt --check clean

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Size Increased — +0.0 KB

118.3 KB unpacked

@pkg-pr-new

pkg-pr-new Bot commented Jun 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@bomb.sh/tty@84

commit: 1ca32af

@natemoo-re
natemoo-re force-pushed the nm/repro/vs16-emoji-width branch from 748a88e to c164d29 比较 June 5, 2026 06:14
@codspeed-hq

codspeed-hq Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 10 untouched benchmarks


Comparing nm/repro/vs16-emoji-width (1ca32af) with main (d4bc79b)

Open in CodSpeed

measure() and render_text() summed per-codepoint widths with no
grapheme awareness, so a base codepoint followed by U+FE0F (variation
selector-16) measured as base-width + 0 instead of one width-2 emoji
cluster. Add a one-codepoint lookahead to both loops: when the next
codepoint is U+FE0F, treat the pair as a single width-2 cluster, place
only the base glyph, and consume both. The wcwidth table is untouched.

The repro's bordered-fit assertion was rescoped to the render path;
the separate "fit() border does not reserve layout space" behavior is
tracked in its own issue.

Fixes #81
注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

项目

None yet

Development

Successfully merging this pull request may close these issues.

🐛 VS16 (U+FE0F) emoji measured at the wrong width

1 participant