[feature]: implement Undo/Redo actions#1970
Open
Necrom4 wants to merge 5 commits into
Open
Conversation
Undo steps HEAD back through the reflog and redo replays it forward. Each move is tagged in the reflog so the stack survives reopening neogit, and both bail out during a rebase or merge.
Adds n_undo/n_redo actions and wires them up in the status buffer. Plain z is already a fold prefix here, so undo/redo sit on the meta keys instead.
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.
Implementation of Lazygit’s reflog undo/redo magic inspired by jesseduffield/lazygit#718
This adds basic undo/redo in the status buffer, bound to
<m-u>and<m-r>.It works off the reflog: undo moves HEAD back to where it was before the last action, and redo steps it forward again. Each move is tagged in the
reflog so your place in the history isn't lost when you close and reopen. It covers things that move HEAD (commits, amends, merges, rebases,
resets) and is disabled while a rebase or merge is in progress.
I used
<m-u>/<m-r>rather thanz/<c-z>sincezis already a fold prefix in the status buffer. This does not close #1839, because it can’t revert simple stages, but I could look into implementing that.Open to changing the default keys if you'd prefer something else. I may also look into further improvements Lazygit added after this PR, even though from testing this already works exactly how I expected it to, and how I use it everyday with Lazygit.