fix: pad description box rows by display width - #478
Open
NoirVoider wants to merge 1 commit into
Open
NoirVoider wants to merge 1 commit into
NoirVoider wants to merge 1 commit into
Conversation
truncateMultilineText() padded each wrapped row with String#padEnd, which counts UTF-16 code units, while renderBox() draws the border assuming the row occupies exactly `width` terminal columns. Any description whose display width differs from its code-unit length (CJK text, BMP-wide emoji such as U+2B50, ZWJ emoji sequences) produced a misaligned right border; ZWJ sequences pulled it inwards. Reuse the existing display-width helper (wcPadEnd/wcswidth) so the description box matches truncateText(), which already pads by width.
Author
|
@microsoft-github-policy-service agree |
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.
Description
truncateMultilineText()padded each wrapped row withString#padEnd, which counts UTF-16 code units, whilerenderBox()draws the description box border assuming the row occupies exactlywidthterminal columns. Descriptions containing characters whose display width differs from their code-unit length (CJK, BMP-wide emoji such as U+2B50, ZWJ emoji sequences) therefore produced a misaligned right border.This reuses the display-width helper that already exists in the same file and is already used by
truncateText(), so both boxes pad by display width. ASCII descriptions are unaffected (wcswidth(text) === text.length).Fixes #477
Before / after (
width = 28, i.e.descriptionWidth - borderWidth)padEnd)wcPadEnd)Run OpenCode with a message以一条消息运行 OpenCode⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐(U+2B50)🚀🚀🚀🚀🚀🚀🚀🚀(U+1F680)👨👩👧👨👩👧👨👩👧Tests
Added a
truncateMultilineTextsuite tosrc/tests/utils/ui.test.ts:renderBox(truncateMultilineText(...), width + 2)lines are exactlywidth + 2columnsmaxHeighttruncation still marks the last line with…3 of the new assertions fail on
main, pass with the fix:Full suite with the fix: