Skip to content

Fix TTY table emoji width for ZWJ and skin-tone sequences#34

Merged
xenodium merged 1 commit into
xenodium:mainfrom
ewilderj:exp-tty-grapheme-width
May 24, 2026
Merged

Fix TTY table emoji width for ZWJ and skin-tone sequences#34
xenodium merged 1 commit into
xenodium:mainfrom
ewilderj:exp-tty-grapheme-width

Conversation

@ewilderj
Copy link
Copy Markdown
Contributor

@ewilderj ewilderj commented May 24, 2026

A small fix to ensure tty-only users also get nice emoji alignment :-)

Modern terminals (Ghostty, WezTerm, Kitty, iTerm2) shape ZWJ sequences and skin-tone modifiers into single 2-cell glyphs, but string-width sums their components — so tables with complex emoji misalign in TTY mode.

This routes the TTY width and padding paths through a new markdown-overlays--string-width that splits into grapheme clusters and forces width 2 for ZWJ, VS-16, and Fitzpatrick modifiers.

Terminal detection is a small TERM_PROGRAM allowlist (Ghostty, WezTerm, Kitty, iTerm2), memoized on a frame parameter. Setting the markdown-overlays-modern-tty frame parameter to yes or no overrides the detection.

Tests cover the grapheme-width rules and the allowlist/denylist behavior.

@xenodium xenodium merged commit e8bdf6d into xenodium:main May 24, 2026
@xenodium
Copy link
Copy Markdown
Owner

Thanks for the PR!

@ewilderj
Copy link
Copy Markdown
Contributor Author

Thanks! FWIW the same TTY shaping fix would apply to the new renderer in xenodium/agent-shell#597 — its --table-needs-pixel-p covers ZWJ and regional-indicator pairs but not VS-16 or skin-tone modifiers, and it has no TTY path

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.

2 participants