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 recording of unicode characters #64

Merged
merged 1 commit into from
Jun 19, 2023

Conversation

MilesCranmer
Copy link
Contributor

@MilesCranmer MilesCranmer commented Jun 19, 2023

Fixes #63. (as in, I no longer see the error)

The fix is to replace

    i = min(length(rec.text), rec.cursor_index)
    a = rec.text[begin:i]
    b = rec.text[i+1:end]

with

    i = min(length(rec.text), rec.cursor_index)
    a = ""
    b = ""
    if i > 0
        a = rec.text[begin:nextind(rec.text, i-1)]
        b = rec.text[nextind(rec.text, i):end]
    end

which accounts for strings which are not uniformly indexed, like "aαbβcγ" which has its indices at 1, 2, 4, 5, 7, 8.

@MilesCranmer MilesCranmer changed the title Fix recording of unicode characters in record Fix recording of unicode characters Jun 19, 2023
@caleb-allen caleb-allen added the bug Something isn't working label Jun 19, 2023
Copy link
Owner

@caleb-allen caleb-allen left a comment

Choose a reason for hiding this comment

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

This is wonderful, thank you!

@caleb-allen caleb-allen merged commit 302d5de into caleb-allen:master Jun 19, 2023
@MilesCranmer MilesCranmer deleted the fix-unicode-record branch June 19, 2023 21:48
caleb-allen pushed a commit that referenced this pull request Jul 14, 2023
Fixes #63. (as in, I no longer see the error)

The fix is to replace

```julia
    i = min(length(rec.text), rec.cursor_index)
    a = rec.text[begin:i]
    b = rec.text[i+1:end]
```
with
```julia
    i = min(length(rec.text), rec.cursor_index)
    a = ""
    b = ""
    if i > 0
        a = rec.text[begin:nextind(rec.text, i-1)]
        b = rec.text[nextind(rec.text, i):end]
    end
```
which accounts for strings which are not uniformly indexed, like "aαbβcγ" which has its indices at `1, 2, 4, 5, 7, 8`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unicode display errors
2 participants