Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@samcoe
Copy link
Contributor

@samcoe samcoe commented Sep 11, 2020

Improve logic for determining string truncation and string display width. This new logic uses a combination of https://github.com/mattn/go-runewidth and https://github.com/rivo/uniseg. This should result in better alignment when using the issue list command.

Note: func graphemeWidth is not always 100% accurate so there might still be some misalignment cases that exist but it has more robust rune recognition (due to go-runewidth) than our previous implementation.

closes #1454

@samcoe samcoe self-assigned this Sep 11, 2020
@samcoe samcoe force-pushed the fix-issue-list-emoji-bug branch from 5b450e3 to 939bf01 Compare September 11, 2020 09:51
@samcoe samcoe marked this pull request as ready for review September 11, 2020 09:52
@samcoe samcoe force-pushed the fix-issue-list-emoji-bug branch from 939bf01 to e5466c0 Compare September 11, 2020 09:57
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

How does the new approach work with emoji that are composed of sequences? Will we still need to handle them separately & explicitly?

@samcoe
Copy link
Contributor Author

samcoe commented Sep 11, 2020

@mislav For emoji that are composed of multiple runes we now iterate through the runes and choose the display width for the first non-zero width rune and assume that the emoji is that width. Previously we would just be counting the display width of all the runes in the emoji. For example:

Emoji String: 🇪🇷
Emoji Runes: [127466, 127479]
Rune 127466 Width: 1
Rune 127479 Width: 1
Previous Display Width: 2
New Display Width: 1

This should work fine for most cases, but if we are alerted to any emoji that don't fit that algorithm we can special case them in the code without much difficulty.

@samcoe samcoe merged commit b34fe81 into trunk Sep 12, 2020
@samcoe samcoe deleted the fix-issue-list-emoji-bug branch September 12, 2020 17:08
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.

Issue listing is misaligned when labels contain emoji

2 participants