-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use lipgloss.Width
to calculate DisplayWidth
#159
Conversation
@williammartin Had to switch to Added the multi-byte emoji test case as well! |
uniseg
to calculate DisplayWidth
lipgloss.Width
to calculate DisplayWidth
Thanks. If we're expecting I suppose for someone out there this could be a breaking change but I think it's edge case enough that I'd rather just accept it and then people could fix any hacky workarounds they might have had. |
Yep, there is already a test case for that! The tests were failing when I simply had |
Test case for ignoring ANSI sequences when calculating width is here: https://github.com/cli/go-gh/blob/trunk/pkg/text/text_test.go#L282-L287 (fails when just using |
Well, that's testing the public API of |
Ah you're totally right, there is also a test case directly for color codes in Lines 360 to 363 in 5840c44
Happy to add more test cases though if you want / prefer! |
Haha sorry I should have also looked closer. I think I got red herring-ed by your link because I assumed if it existed already you would definitely have linked it 😅 I can confirm that test fails just using
No need for extra tests, this looks great to me, once I pull it into |
Haha all good! I kind of missed that test case the first time as well and definitely should have linked to that! |
Before![]() (wow such codepoints: https://ardislu.dev/biggest-unicode-grapheme-cluster) After![]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pulled this into cli/cli
and it passed all the tests.
LGTM thanks a lot.
Fixes cli/cli#9018
Uses
lipgloss.Width
to calculateDisplayWidth
which correctly aligns emojis.