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

latex characters cause certain actions to break on the last two characters #95

Closed
ArbitRandomUser opened this issue Feb 20, 2024 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ArbitRandomUser
Copy link

seems to be triggered by certain latex characters are in the prompt

julia> 0b0000 ⊻ 0b0000

deleting the last 0 (and second last 0) character with x , or replacing (r) does not work, ( not sure other ways this is broken , but these two are what i noticed as of now)

pkg version:

[51b3953f] VimBindings v0.3.12
@caleb-allen
Copy link
Owner

Thank you for the report—on the surface, it seems it could be related to these other issues related to bad behavior when the cursor is at the end of the prompt, #92 and #93. Or perhaps it's an issue of counting the text width incorrectly when determining the valid range for an operation, because this would explain why the bug surfaces with special characters like which occupy more than one byte.

Ideally, no operation should be operating directly with bytes, but alas I wrote much of the code before I properly understood Julia's String implementation.

Hopefully there's a common root cause that will get all these fixed for the next version

@caleb-allen caleb-allen added the bug Something isn't working label Feb 20, 2024
@caleb-allen caleb-allen added this to the 0.3.13 milestone Feb 20, 2024
@caleb-allen caleb-allen self-assigned this Feb 20, 2024
@caleb-allen
Copy link
Owner

Ha, okay this is funny. I wrote a unit test containing your example, and then identified what I believe is the source of the bug (indeed using the byte length of the prompt). But still, the test is failing.

Turns out that the utility function I created to help write concise tests is itself broken! The idea is that I ought to be able to write a string which is transformed into a test prompt buffer, and it just needs to contain a pipe | where the cursor ought to be (and optionally a mode indicator by wrapping the mode in a pipe, e.g. |i| for insert mode). For instance:

julia> testbuf("f(x) = x * |2")
 VimBuffer("f(x) = x * |n|2")

But for a prompt containing characters represented by multiple codeunits...

julia> testbuf("0b0000 ⊻ 0b000|0")
 VimBuffer("0b0000 ⊻ 0b0|n|000")

It does not behave well. Oops! Quite a challenge to hammer a nail when your hammer is only a hammer for the easy nails!

Anyways, I'm fixing up that test buffer mechanism, certainly needs to be rock solid. Then I'll test the changes I've made that I am hopeful fix this (it does in my REPL) and put out a release once that's verified.

@caleb-allen
Copy link
Owner

This should be fixed in #97 and will be included in the next release

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

No branches or pull requests

2 participants