-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Unicode display errors #63
Comments
caleb-allen
pushed a commit
that referenced
this issue
Jun 19, 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`.
I think you're right, not exactly the same #13 but somewhat related. The solution to #13 needs to essentially do what your solution is in #64 and apply it to buffer operations (in other words, don't assume 1 byte = 1 code point); the package is pretty naive with characters right now. Anyways, thanks for the report and the fix! |
caleb-allen
pushed a commit
that referenced
this issue
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
I think this is unrelated to #13 but please close if so.
If I open up julia with VimBindings.jl set up and write:
I see the following error (click to expand):
I think this is unrelated to #13 because it is about indexing strings, rather than moving in buffers (which does not face this issue). I recently had a similar issue on SymbolicRegression.jl when trying to split a string: MilesCranmer/SymbolicRegression.jl#223. Basically, the string
"ρρ"
has indices at1
and4
, but nowhere in between. This is a quirk of how unicode is stored I guess.The solution is to use the more generic operations, like
eachindex
,nextind
,prevind
, anditerate
, rather than indexing with linear integers. One thing I've found easiest is to make an index array withI = collect(eachindex(s))
, and then index the string withs[I[i]]
, wherei
goes from1
tolength(s)
.Fixed with #64
The text was updated successfully, but these errors were encountered: