Use lipgloss.Width to calculate DisplayWidth#159
Use lipgloss.Width to calculate DisplayWidth#159williammartin merged 2 commits intocli:trunkfrom maaslalani:trunk
lipgloss.Width to calculate DisplayWidth#159Conversation
|
@williammartin Had to switch to Added the multi-byte emoji test case as well! |
uniseg to calculate DisplayWidthlipgloss.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
|
williammartin
left a comment
There was a problem hiding this comment.
I pulled this into cli/cli and it passed all the tests.
LGTM thanks a lot.



Fixes cli/cli#9018
Uses
lipgloss.Widthto calculateDisplayWidthwhich correctly aligns emojis.