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

Fixes Incorrect Index Behavior in Unicode Name Selector #3219

Merged
merged 2 commits into from
Jan 7, 2021

Conversation

purxiz
Copy link
Contributor

@purxiz purxiz commented Jan 6, 2021

The bases for the index were being decoded as base 16, despite being displayed as base 36 (0-9, a-z). This fix makes it so typing 'search string .index' returns the unicode char at the expected index, based on what is displayed by the program. The previous behavior was that to enter the symbol that is displayed at index 18, you would actually have to type .2c, since 18 base 36 = 2c base 16. This fix makes it so to type the symbol at index 18, you type .18, which seems more reasonable

It also slightly changes the behavior. Before, only the selected result would appear. For example, musical note musical note .18 would only show a single result (with index 0 always), since there was only a single result at index 18. Now, searching by index doesn't remove codepoints/results, it simply highlights the result at the correct index for you.

This is my first PR to this project, so sorry if I've violated any coding styles. I will say I'm not particularly happy with how I handled the iindex_word variable in the update_codepoints function, nor am I sure that it's totally sane to set the index as part of set_codepoints. Since setting the index to 0 was a side effect of set_codepoints before, I figured it was okay.

That said, I just wanted to submit something that works :)

Fixes #3221

The bases for the hint were being decoded as base 16, despite being displayed as base 36 (0-9, a-z). This fix makes it so typing 'search string .index' returns the unicode char at the expected index, based on what is displayed by the program.

It also slightly changes the behavior. Before, only the selected result would appear. For example, musical note `musical note .18` would only show a single result, since there was only a single result at index 18. Now, searching by index doesn't remove codepoints/results, it simply highlights the result at the correct index for you.
I moved the location of the check for an overflowing index to avoid a type error that was revealed by mypy. I also think this is a better place to put it from a code standpoint in general...
@purxiz purxiz changed the title fixes incorrect hint base Fixes Incorrect Index Behavior in Unicode Name Selector Jan 6, 2021
@kovidgoyal kovidgoyal merged commit 31cb688 into kovidgoyal:master Jan 7, 2021
@purxiz purxiz deleted the bugfix-unicode-names-input branch January 7, 2021 13:24
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.

Indices for name section of unicode input use incorrect base
2 participants