helix/helix-term/tests/test
Michael Davis 4bd17e542e
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
2025-01-15 10:36:29 -05:00
..
commands Fix offset tracking in `insert_newline` 2025-01-15 10:36:29 -05:00
languages Trim all trailing whitespace on insert_newline 2024-12-05 20:53:53 +09:00
auto_indent.rs Factor out line ending handling in integration tests (#9921) 2024-03-31 07:12:17 -05:00
auto_pairs.rs Factor out line ending handling in integration tests (#9921) 2024-03-31 07:12:17 -05:00
commands.rs Fix a typo in join_selections (#12452) 2025-01-08 08:42:41 -06:00
helpers.rs Read symlink when writing files (#10339) 2024-04-11 20:49:16 -05:00
movement.rs test: match around closest pair tree-sitter version 2024-04-24 16:36:13 -04:00
prompt.rs flush writes on force quit (#4397) 2022-10-21 13:28:29 +09:00
splits.rs Use a temporary file for writes (#9236) 2024-03-31 17:43:09 -05:00