Skip to content
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 crash when deleting with multiple cursors #6024

Merged
merged 4 commits into from
May 18, 2023

Commits on May 3, 2023

  1. fix panic when deleting overlapping ranges

    Some deletion operations (especially those that use indentation)
    can generate overlapping deletion ranges when using multiple cursors.
    To fix that problem a new `Transaction::delete` and
    `Transaction:delete_by_selection` function were added. These functions
    merge overlapping deletion ranges instead of generating an invalid
    transaction. This merging of changes is only possible for deletions
    and not for other changes and therefore require its own function.
    
    The function has been used in all commands that currently delete
    text by using `Transaction::change_by_selection`.
    pascalkuthe committed May 3, 2023
    Configuration menu
    Copy the full SHA
    0c7c3bd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d445aa2 View commit details
    Browse the repository at this point in the history
  3. don't move cursor while forward deleting in append mode

    Currently, when forward deleting (`delete_char_forward` bound to `del`,
    `delete_word_forward`, `kill_to_line_end`) the cursor is moved to the
    left in append mode (or generally when the cursor is at the end of the
    selection). For example in a document `|abc|def`  (|indicates selection)
    if enter append mode the cursor is moved to `c` and the selection
    becomes: `|abcd|ef`. When deleting forward (`del`) `d` is deleted. The
    expectation would be that the selection doesn't shrink so that `del`
    again deletes `e` and then `f`. This would look as follows:
    
    `|abcd|ef`
    `|abce|f`
    `|abcf|`
    `|abc |`
    
    This is inline with how other editors like kakoune work.
    However, helix currently moves the selection backwards leading to the
    following behavior:
    
    `|abcd|ef`
    `|abc|ef`
    `|ab|ef`
    `ef`
    
    This means that `delete_char_forward` essentially acts like
    `delete_char_backward` after deleting the first character in append
    mode.
    
    To fix the problem the cursor must be moved to the right while deleting
    forward (first fix in this commit). Furthermore, when the EOF char is
    reached a newline char must be inserted (just like when entering
    appendmode) to prevent the cursor from moving to the right
    pascalkuthe committed May 3, 2023
    Configuration menu
    Copy the full SHA
    013fa65 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d605a34 View commit details
    Browse the repository at this point in the history