-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix offset tracking in
insert_newline
#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 #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 #12461 Fixes #12495 Fixes #12539
- Loading branch information
1 parent
99d33c7
commit 4bd17e5
Showing
2 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters