1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-27 00:51:18 +02:00

Remove the pick vs. pull hack

Previously we would call pullFiles() from the pick() handler if we were not in a
rebase, assuming that the default keybinding for both is "p". This needn't be
the case of course, if the user has remapped one or the other.

The consequence of this was that swapping the keybindings for "pullFiles" and
"pushFiles" would work in all panels except the Commits panel (unless "pick" was
also remapped in the same way).

Fix this by using the new AllowFurtherDispatching mechanism of DisabledReasons
to pass the keybinding on to the next handler.
This commit is contained in:
Stefan Haller
2025-06-01 17:25:38 +02:00
parent 3e26be9845
commit c752f3529b
2 changed files with 4 additions and 13 deletions

View File

@ -144,14 +144,6 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
),
Description: self.c.Tr.Pick,
Tooltip: self.c.Tr.PickCommitTooltip,
// Not displaying this because we only want to display it when a TODO commit
// is selected. A keybinding is displayed in the options view if Display is true,
// and if it's not disabled, but if we disable it whenever a non-TODO commit is
// selected, we'll be preventing pulls from happening within the commits view
// (given they both use the 'p' key). Some approaches that come to mind:
// * Allow a disabled keybinding to conditionally fallback to a global keybinding
// * Allow a separate way of deciding whether a keybinding is displayed in the options view
DisplayOnScreen: false,
},
{
Key: opts.GetKey(opts.Config.Commits.CreateFixupCommit),
@ -623,9 +615,7 @@ func (self *LocalCommitsController) pick(selectedCommits []*models.Commit) error
return self.updateTodos(todo.Pick, selectedCommits)
}
// at this point we aren't actually rebasing so we will interpret this as an
// attempt to pull. We might revoke this later after enabling configurable keybindings
return self.pullFiles()
panic("should be disabled when not rebasing")
}
func (self *LocalCommitsController) interactiveRebase(action todo.TodoCommand, startIdx int, endIdx int) error {
@ -1476,8 +1466,7 @@ func (self *LocalCommitsController) pickEnabled(selectedCommits []*models.Commit
}
if !self.isRebasing() {
// if not rebasing, we're going to do a pull so we don't care about the selection
return nil
return &types.DisabledReason{Text: self.c.Tr.PickIsOnlyAllowedDuringRebase, AllowFurtherDispatching: true}
}
return self.midRebaseCommandEnabled(selectedCommits, startIdx, endIdx)

View File

@ -369,6 +369,7 @@ type TranslationSet struct {
RewordNotSupported string
ChangingThisActionIsNotAllowed string
NotAllowedMidCherryPickOrRevert string
PickIsOnlyAllowedDuringRebase string
DroppingMergeRequiresSingleSelection string
CherryPickCopy string
CherryPickCopyTooltip string
@ -1459,6 +1460,7 @@ func EnglishTranslationSet() *TranslationSet {
RewordNotSupported: "Rewording commits while interactively rebasing is not currently supported",
ChangingThisActionIsNotAllowed: "Changing this kind of rebase todo entry is not allowed",
NotAllowedMidCherryPickOrRevert: "This action is not allowed while cherry-picking or reverting",
PickIsOnlyAllowedDuringRebase: "This action is only allowed while rebasing",
DroppingMergeRequiresSingleSelection: "Dropping a merge commit requires a single selected item",
CherryPickCopy: "Copy (cherry-pick)",
CherryPickCopyTooltip: "Mark commit as copied. Then, within the local commits view, you can press `{{.paste}}` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `{{.escape}}` to cancel the selection.",