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: finding utf-8 strings failed to select their location. #1902

Merged
merged 2 commits into from
Sep 15, 2024

Conversation

paxcut
Copy link
Contributor

@paxcut paxcut commented Sep 14, 2024

other separate, but closely related fixes are:

  • fix: The previous fix also solved the (unreported) bug of being unable to select utf-8 works by double-clicking.
  • fix: The move to next/previous word (Ctr-arrow) behaved differently depending on the direction. I made both the move left/right functions share a much simpler algorithm and rewrote the find start/end of word functions share the same code structure.

Problem description

The code was using the byte index of the match into the utf-8 string to store the match locations, but the code that sets the selection uses the char index into the utf-8 string instead. Another problem was that the search uses the byte index to determine if it needs to find more matches.

Implementation description

Both problems were solved by introducing two functions to switch from coordinates in units of bytes to coordinates in units of chars and vice versa.

paxcut and others added 2 commits September 14, 2024 05:04
The code was using the byte index of the match into the utf-8 string to store the match locations, but the code that sets the selection uses the char index into the utf-8 string instead. Another problem was that the search uses the byte index to determine if it needs to find more matches. Both problems were solved by introducing two functions to switch from coordinates in units of bytes to coordinates in units of chars and vice versa.

fix: The previous fix also solved the (unreported) bug of being unable to select utf-8 works by double-clicking.

fix: The move to next/previous word (Ctrl-arrow) behaved differently depending on the direction. I made both the move left/right functions share a much simpler algorithm and rewrote the find start/end of word functions share the same codestructure.
@WerWolv WerWolv merged commit 3c060cc into WerWolv:master Sep 15, 2024
15 checks passed
@paxcut paxcut deleted the Utf8Navigation branch September 17, 2024 22: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.

2 participants