-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Is your feature request related to a problem? Please describe.
Currently the 'r' keybinding only brings up the rebasing menu in the branches view and remote branches view.
Describe the solution you'd like
I want it to bring up the rebasing menu in any view that contains something you can rebase onto which means:
- commits
- sub-commits
- reflog commits
- tags
I think that's everything.
The tricky part is that the 'r' keybinding is already used to support rewording a commit from within lazygit. 'R' is used for rewording a commit in an editor. We have other places where 'R' is used for renaming e.g. the branches view. So I propose that 'R' now opens a menu with an option for rewording from within lazygit ('i') and rewording from an external editor ('e').
Yes, nobody is more upset by extra keypresses than me, but I think this is necessary. I'm pretty sure that people will sometimes want the external editor and sometimes want the internal editor, so having a config for it wouldn't work, unless the config was a choice between three options: always-internal, always-external, and show-menu. But I don't want to do that unless people actually want it.
Describe alternatives you've considered
This is getting pretty fine-grained but if people more frequently rebase than they do rename, we could use 'r' for rebase and 'R' for rename (slightly less friction), but if we did that I'd want to use 'm' for merge instead of 'M', and 'm' is currently being used to show the general rebase/merge options (continue/abort). We could move that to 'ctrl+r' which is more intuitive but that's being used by the recent repos view. Or we could just move it to 'M'. But that's a lot of shuffling around for minor benefit.
Additional context
In terms of implementation, the best way to do this is to make RebaseController and attach it to the all the contexts that contain things you can rebase onto:
// pkg/gui/controllers.go
for _, context := range []controllers.CanViewWorktreeOptions{
gui.State.Contexts.LocalCommits,
gui.State.Contexts.ReflogCommits,
gui.State.Contexts.SubCommits,
gui.State.Contexts.Branches,
gui.State.Contexts.RemoteBranches,
gui.State.Contexts.Tags,
} {
controllers.AttachControllers(context, controllers.NewRebaseController(common, context))
}You can copy the code from pkg/gui/controllers/worktree_options_controller.go as a starting point.
Then it's just a matter of:
- removing the rebase action from the branches controller and remote-branches controller
- updating the places that use 'r' for rename to now use 'R'
- putting the commit reword actions behind a menu