Skip to content
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

Fix wrong unit when split string #839

Merged
merged 1 commit into from
Nov 7, 2024
Merged

Conversation

petricavalry
Copy link
Contributor

@petricavalry petricavalry commented Sep 30, 2024

Fixes #837.

let (match_str, remaining_str) = suggestion.value.split_at(match_len);

split_at expect byte offset.

let match_len = self.working_details.shortest_base_string.width();

But we given (got from width) isn't.

Thanks for all amazing works in reedline.

@sholderbach
Copy link
Member

Yeah for anything involving string splitting .len is the relevant thing to get to the indices, while .width serves as a best guess for the layout width in the terminal. We need to be sure that the right thing is used in the right place.

There seems to be some preexisting history of display bugs leading to this

@petricavalry
Copy link
Contributor Author

petricavalry commented Sep 30, 2024

Thanks for your help. I can't reproduce #793 after change this line. match_len is used only to split string.

@Jiogo18
Copy link
Contributor

Jiogo18 commented Nov 7, 2024

Works well, sorry about that.

The comment I wrote in #794 doesn't make sense, it is about str_len

shortest_base_string (in case all the results contains lots of special characters)

@sholderbach
Copy link
Member

Thx for the fix!

@sholderbach sholderbach merged commit 7a1b344 into nushell:main Nov 7, 2024
6 checks passed
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.

Panic when completion menu items contains UTF-8 characters and (
3 participants