From c752f3529b97a88f3a3ecd6afc2dfb6a8c37ab31 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 1 Jun 2025 17:25:38 +0200 Subject: [PATCH] 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. --- pkg/gui/controllers/local_commits_controller.go | 15 ++------------- pkg/i18n/english.go | 2 ++ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 2b6f3d5c0..e9cd9cbc0 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -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) diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 468231f9b..36a119c36 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -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.",