git: Introduce restore and next action#50324
Merged
Conversation
Similar to `git::StageAndNext` and `git::UnstageAndNext`, these changes introduce a `git::RestoreAndNext` action. There's a `TODO!` regarding multiple calls to `Editor.change_selections` which we can likely consolidate, and tests will be added in a next commit. Co-authored-by: Afonso <4775087+afonsograca@users.noreply.github.com>
Co-authored-by: Afonso <4775087+afonsograca@users.noreply.github.com>
* Update `Editor.restore_and_next` to leverage `Editor.go_to_next_hunk` * Remove irrelevant `TODO!` * Update tests to confirm behavior change in `Editor.restore_and_next`
Update the default keymaps for all platforms (macOS, Windows & Linux) in order to map the default binding for `git::Restore` to map to `git::RestoreAndNext` when the user is focused on the `GitDiff` view only. This way we don't change the default behavior when the user is editing a single file or a multibuffer but, in the context of the git diff, are able to have the diff hunk be restored and move to the next one.
- Update the `editor::Editor::hunk_before_position` and `editor::Editor::hunk_after_position` methods to accept a `wrap_around` parameter, contorlling whether the caller whishes for the search for the previous or next hunk to wrap around in the buffer - Refactor all callers to default this parameter to true - Refactor `editor::Editor::do_stage_or_unstage_and_next` to leverage this new parameter in `editor::Editor::go_to_hunk_before_or_after_position`, keeping the logic of only wrapping around if `multi_buffer::MultiBuffer::all_diff_hunks_expanded` returns false - Refactor `editor::Editor::restore_and_next` method to use the wrap around logic as `editor::Editor::do_stage_or_unstage_and_next`
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before you mark this PR as ready for review, make sure that you have:
Release Notes:
git: restore and nextaction that restores the diff hunk at the cursor and conditionally moves to the next one. In the git diff view, the default restore keybinding (cmd-alt-zon macOS,ctrl-k ctrl-ron Linux/Windows) now triggers this action instead ofgit: restore.