-
-
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
fix(auto_pairs): fix auto pairs with crlf #1470
Conversation
@CptPotato would you please be able to test this locally on your Windows machine and verify the fix? |
helix-core/Cargo.toml
Outdated
fern = "0.6" | ||
chrono = { version = "0.4", default-features = false, features = ["clock"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these two imports still necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, they were necessary for seeing logs with unit tests. Though it might be worthwhile to leave this out until we set up common unit testing code for things like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this for now, I personally either use a debugger or switch to println!()
when debugging then remove it before commiting
I've only done a quick test but it seems to work for me now 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good otherwise, I've been trying to simplify this but haven't found a way yet. I think it might make things simpler if get_next_range
is implemented per operation (open/close) since close always takes the if len_inserted == 0
path.
helix-core/Cargo.toml
Outdated
fern = "0.6" | ||
chrono = { version = "0.4", default-features = false, features = ["clock"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this for now, I personally either use a debugger or switch to println!()
when debugging then remove it before commiting
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
197748b
to
d213727
Compare
Yeah, the function is bigger than I would like, but I also can't think of a good way to simplify it.
This is actually not true, because you can be inserting a closing character by itself, in which case it must be 1 with the current code, and shares logic with the open path. And after we have more flexible configs a la #1418, it could theoretically be longer lengths from international keyboards, in which case it shares even more logic.
Ok, done. I had been using But yeah, this should be something in the testing harness as part of #115 instead of scattering logging code across the code base in random modules. |
Auto pairs were resulting in incorrect ranges in the 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 #1436