Skip to content

Conversation

@MDrakos
Copy link
Member

@MDrakos MDrakos commented Jan 14, 2021

@MDrakos MDrakos requested a review from Naatan January 14, 2021 22:51
@Naatan Naatan requested a review from mdrohmann January 14, 2021 22:57
@Naatan
Copy link
Contributor

Naatan commented Jan 14, 2021

@mdrohmann I'm still not entirely clear on how runes work. Can you double check this won't have any adverse effects?

func GetCroppedText(text string, maxLen int) CroppedLines {
entries := make([]CroppedLine, 0)
colorCodes := colorRx.FindAllStringSubmatchIndex(string(text), -1)
colorCodes := colorRx.FindAllStringSubmatchIndex(text, -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense. It's certainly correct to use []rune as the argument type here.

len("✔ab") == 4, len([]rune("✔ab")) == 3 As we are trying to limit the "visible width", we are interested in the latter number here.

BTW: This will still not be enough, if we every support weird East-Asian locales, as these runes may be two characters wide(!). Then we'll have to use something like this

But I think that this is a problem for our future selves...

An example of runes that are two characters wide:

つつ
1234

@MDrakos MDrakos merged commit 9ec4383 into master Jan 15, 2021
@MDrakos MDrakos deleted the crop-update-176372179 branch May 3, 2021 16:37
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.

4 participants