Skip to content

fix(tostring): resolve emoji shorthands to Unicode for correct table column widths#483

Merged
OXY2DEV merged 1 commit intoOXY2DEV:mainfrom
ImmanuelHaffner:fix/emoji-tostring-width
Mar 20, 2026
Merged

fix(tostring): resolve emoji shorthands to Unicode for correct table column widths#483
OXY2DEV merged 1 commit intoOXY2DEV:mainfrom
ImmanuelHaffner:fix/emoji-tostring-width

Conversation

@ImmanuelHaffner
Copy link
Contributor

Problem

Table columns containing emoji shortcodes (e.g. :rocket:, :sparkles:) render with misaligned borders. The column width calculation overestimates cells that contain emojis.

Root cause

md_str.emoji() in tostring.lua strips the colons from shortcodes but never resolves them to the actual Unicode character:

Shortcode tostring returned strdisplaywidth Actual display strdisplaywidth Δ
:sparkles: sparkles 8 2 +6
:rocket: rocket 6 🚀 2 +4
:wrench: wrench 6 🔧 2 +4

The inline renderer (inline.emoji) correctly replaces the shortcode with the Unicode symbol via symbols.shorthands[], but the width-calculation path never did — so col_widths was inflated by the difference.

Fix

Resolve the shortcode through symbols.shorthands[] in md_str.emoji() (falling back to the stripped name if the symbol isn't found), matching what the inline renderer actually displays.

…calculation

md_str.emoji() was stripping the colons from shortcodes (e.g.
:rocket: → 'rocket') but never resolving them to the actual Unicode
emoji character.  This caused strdisplaywidth() to return the name
length (e.g. 6 for 'rocket') instead of the true on-screen width (2
for '🚀'), producing column width overestimates and misaligned table
borders.

Now resolve through symbols.shorthands[] — matching what the inline
renderer actually displays — so width calculations are accurate.
@OXY2DEV OXY2DEV merged commit 38a14a4 into OXY2DEV:main Mar 20, 2026
1 check passed
@ImmanuelHaffner ImmanuelHaffner deleted the fix/emoji-tostring-width branch March 20, 2026 14:11
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