-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Incorrect auto pair at line ending #1436
Comments
Looks like this behaviour started with #1254 |
\cc @dead10ck |
Very strange, this must be a platform specific issue. Does this still happen if you set line endings to just lf? |
Yes, setting line endings to |
Interesting, and setting to crlf on Linux did not reproduce for me. I'll dig into this later tonight. |
@CptPotato in the meantime, would you be able to generate some debug logs for me? Could you clear any current logs you might have and then:
Then save this log by itself, clear the standard log file again and do:
Then save this log by itself. These logs will help me dig into it. Thanks! |
I can reproduce the bug on linux if I open a file with For example with python: f = open("test.txt", "wb")
f.write(b"\x0A\x0D") # CR, LF
f.close() edit: here are the logs: helix.log
helix.log (with space)
|
Ah, I see the problem. It's here: helix/helix-core/src/auto_pairs.rs Lines 75 to 91 in bd0d20a
We check if the selection is a single-width cursor by checking if the length of the range is 1; for CRLF, it's actually 2. So it thinks there is a multi-character selection when there is not. Strangely, for me, I did not run into the cursor advancing past the end of the paren, but I did see the selection ending up incorrect. I think what we need to do is check if the number of graphemes in the range is 1 to get the correct behavior. I'll try to fix this soon. Additionally, I noticed from @CptPotato 's logs that the range was actually in the forward direction, when it should have been backward for an insert. I confirmed that when you first open helix and immediately go to insert mode, the range is [0, 1). If you then delete anything you enter and go to insert mode again, in the same empty document, it's [1, 0) as it should be. I would expect this to lead to the behavior of extending the selection, since it's both a 2-code point line ending and in the forward direction. This seems like an unrelated bug. |
Auto pairs were resulting in incorrect ranges in the resulting selections when the line terminators are CRLF (i.e. Windows). It turns out this is because when we were checking if the selection was a single-width cursor, it incorrectly assumed that this would be a single char. This is not the case, as a cursor can cover a multi-code point grapheme. Therefore, we must instead explicitly work with and check graphemes to determine if the cursor should move or extend the selection. Fixes helix-editor#1436
Auto pairs were resulting in incorrect ranges in the resulting when the line terminators are CRLF (i.e. Windows). It turns out this is because when we were checking if the selection was a single-width cursor, it incorrectly assumed that this would be a single char. This is not the case, as a cursor can cover a multi-code point grapheme. Therefore, we must instead explicitly work with and check graphemes to determine if the cursor should move or extend the selection. Fixes helix-editor#1436
Auto pairs were resulting in incorrect ranges in the resulting when the line terminators are CRLF (i.e. Windows). It turns out this is because when we were checking if the selection was a single-width cursor, it incorrectly assumed that this would be a single char. This is not the case, as a cursor can cover a multi-code point grapheme. Therefore, we must instead explicitly work with and check graphemes to determine if the cursor should move or extend the selection. Fixes helix-editor#1436
Auto pairs were resulting in incorrect ranges in the resulting when the line terminators are CRLF (i.e. Windows). It turns out this is because when we were checking if the selection was a single-width cursor, it incorrectly assumed that this would be a single char. This is not the case, as a cursor can cover a multi-code point grapheme. Therefore, we must instead explicitly work with and check graphemes to determine if the cursor should move or extend the selection. Fixes helix-editor#1436
Auto pairs were resulting in incorrect ranges in the resulting when the line terminators are CRLF (i.e. Windows). It turns out this is because when we were checking if the selection was a single-width cursor, it incorrectly assumed that this would be a single char. This is not the case, as a cursor can cover a multi-code point grapheme. Therefore, we must instead explicitly work with and check graphemes to determine if the cursor should move or extend the selection. Fixes #1436
Auto paring of quotes and braces appears to break when the cursor is at the end of a line.
The exact behaviour is not clear to me but here are some notes using braces as an example:
(
, the cursor is not inside the braces()▏
instead of(▏)
helix.mp4
I guess this has something to do with the line endings breaking but I don't know enough about helix' internals to be sure.
(On a side note, if I set the line endings to
lf
and then back tocrlf
helix now reports the line ending ascarriage return
instead ofcrlf
.)Environment
v0.5.0-342-gbd0d20a
compiled from source, also present in 0.6.0 github releaseThe text was updated successfully, but these errors were encountered: