Skip to content

Conversation

@ysthakur
Copy link
Member

@ysthakur ysthakur commented Jan 4, 2026

Fixes #997

We were looking at number of bytes/chars to get the width of the suggestion values and base strings. This didn't work with multibyte characters. The fix is to use the Unicode width of these strings.

This is what the IDE menu looks like with suggestions containing (a multibyte character)

~/reedline| he
             ╭────────────────────────────────────────────────╮
             │hello another very large option for hello wor...│
             │hello world 1                                   │
             │hello world 2                                   │
             │hello world another                             │
             │hello world reedline验                          │
             │hello world something                           │
             │hello world验验验                               │
             ╰────────────────────────────────────────────────╯
~/reedline| hello wo
                   ╭──────────────────────╮
                   │hello world 1         │
                   │hello world 2         │
                   │hello world another   │
                   │hello world reedline验│
                   │hello world something │
                   │hello world验验验     │
                   ╰──────────────────────╯

@fdncred
Copy link
Contributor

fdncred commented Jan 4, 2026

I'm fine with this but I always wonder with things like this, should it be width, unicode-width, or graphemes?

@ysthakur
Copy link
Member Author

ysthakur commented Jan 4, 2026

@fdncred What's the difference between width and unicode-width? I've only been using .width() from the unicode_width crate, which I assume gives the latter.

For string length, I think the only choices that make sense are bytes, chars, and width. If we care about how wide a string looks visually (in other words, how many columns a string will occupy in the terminal), it must be .width(), because a single grapheme can take up multiple columns.

I don't think number of graphemes is ever useful for anything. Graphemes are good when you want to do something with the individual graphemes rather than the whole string (okay that sounds a little silly and obvious but hopefully you get what I mean)

@fdncred
Copy link
Contributor

fdncred commented Jan 5, 2026

Ok. Sounds good.

@ysthakur
Copy link
Member Author

ysthakur commented Jan 5, 2026

Just to be sure, are you okay with this being merged? (there aren't a lot of people around to approve anyway)

Copy link
Contributor

@fdncred fdncred left a comment

Choose a reason for hiding this comment

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

@ysthakur yes, i just wanted to make sure that width() was at least unicode-width's width and not something else. Your explanation of graphemes seems logical to me.

@ysthakur ysthakur merged commit 6c37265 into nushell:main Jan 6, 2026
6 checks passed
@ysthakur ysthakur deleted the ide-menu-width branch January 6, 2026 00:53
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.

Chinese (Full-width) Character Width Issue in IDE Layout Mode

2 participants