-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
thread 'main' panicked at helix-core/src/graphemes.rs:173:5: assertion failed: char_idx <= slice.len_chars() #12495
Comments
ropey-1.6.1
: Called Result::unwrap()
on an Err
value, char index out of bounds
This seems to be a regression. I see the same panic with 25.1 but not with 24.7 (using |
A bisect points to 1e6fe00 |
In this line:
Observations: If you place a cursor at each digit except the last If you do have a cursor at the last If you have a cursor on the 4th, 5th, 6th, 7th and the last 8th digit then the panic won't happen If you have a cursor on the 3rd digit as well as all the above, the panic happens. |
I finally figured it out: #12510 |
helix-editor#12177 changed `insert_newline`'s behavior to trim any trailing whitespace on a line which came before a cursor. `insert_newline` would previously never delete text. Even the whitespace stripping behavior in helix-editor#4854 worked by inserting text - a line ending at the beginning of the line. `global_offs`, a variable that tracks the number of characters inserted between iterations over the existing selection ranges, was not updated to also account for text deleted by the trimming behavior, causing cursors to be offset by the amount of trailing space deleted and causing panics in some cases. To fix this we need to subtract the number of trimmed whitespace characters from `global_offs`. `global_offs` must become an `isize` (was a `usize`) because it may become negative in cases where a lot of trailing whitespace is trimmed. Integration tests have been added for each of these cases. Fixes helix-editor#12461 Fixes helix-editor#12495 Fixes helix-editor#12539
Summary
Helix panics when trying to insert newliens
Reproduction Steps
On the latest release
With the following file, cursor at the beginning:
%
to select full files\d
i
then add a newline<enter>
Backtrace
Helix log
empty
Platform
Linux
Terminal Emulator
wezterm 8e9cf91
Installation Method
Built from source
Helix Version
helix 25.1 (6c9619d)
The text was updated successfully, but these errors were encountered: