fix(tui): measure wide characters by display cells#9
Merged
Conversation
CJK/emoji session titles and project paths were measured in codepoints, so wide glyphs overflowed their column budget, wrapped into the next row, and broke the reverse-video selection bar. Add display_width / clip / pad to formatting (east_asian_width-based, combining marks zero -- an approximation that leaves emoji ZWJ sequences alone), make shorten and short_path truncate by cells, clip Renderer.write by cells, and pad user-content rows (highlight bars, modals, toasts) by cells.
The compact bar label spelled sub-cent as <$.01 while money() uses <$0.01; align the two (the price-split cells widen by one to keep the parens group flush right).
Owner
|
Great one — measuring by cells fixes the CJK column overflow cleanly, and I like that emoji ZWJ/flags are called out as the known approximation rather than papered over. Thanks! |
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.
CJK/emoji session titles and project paths were measured in codepoints, so wide glyphs overflowed their column budget, wrapped into the next row, and broke the reverse-video selection bar.
Adds
display_width/clip/padtoformatting.py(stdlibunicodedata.east_asian_width, combining marks count zero,isascii()fast path for the render loops — an approximation that leaves emoji ZWJ sequences alone, noted in a comment).shortenandshort_pathtruncate by cells,Renderer.writeclips by cells so a wide char never straddles the budget, and the user-content row builders (highlight bars, modals, toasts, the Turns subtotal alignment) pad by cells. Fixed-vocabulary/ASCII-guaranteed content (headers, money, dates, model ids) deliberately stays onlen().Second commit:
money_labelspelled sub-cent as<$.01whilemoney()uses<$0.01; aligned (the price-split paren group widens by one to stay flush right).Tested: 6 new tests (cell counting, clipping never exceeding the budget, exact-width padding, CJK shorten/short_path); suite 310/310, ruff clean;
--demo --htmlsmoke-checked.