Skip to content

Commit c752f35

Browse files
committed
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.
1 parent 3e26be9 commit c752f35

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

pkg/gui/controllers/local_commits_controller.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,6 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
144144
),
145145
Description: self.c.Tr.Pick,
146146
Tooltip: self.c.Tr.PickCommitTooltip,
147-
// Not displaying this because we only want to display it when a TODO commit
148-
// is selected. A keybinding is displayed in the options view if Display is true,
149-
// and if it's not disabled, but if we disable it whenever a non-TODO commit is
150-
// selected, we'll be preventing pulls from happening within the commits view
151-
// (given they both use the 'p' key). Some approaches that come to mind:
152-
// * Allow a disabled keybinding to conditionally fallback to a global keybinding
153-
// * Allow a separate way of deciding whether a keybinding is displayed in the options view
154-
DisplayOnScreen: false,
155147
},
156148
{
157149
Key: opts.GetKey(opts.Config.Commits.CreateFixupCommit),
@@ -623,9 +615,7 @@ func (self *LocalCommitsController) pick(selectedCommits []*models.Commit) error
623615
return self.updateTodos(todo.Pick, selectedCommits)
624616
}
625617

626-
// at this point we aren't actually rebasing so we will interpret this as an
627-
// attempt to pull. We might revoke this later after enabling configurable keybindings
628-
return self.pullFiles()
618+
panic("should be disabled when not rebasing")
629619
}
630620

631621
func (self *LocalCommitsController) interactiveRebase(action todo.TodoCommand, startIdx int, endIdx int) error {
@@ -1476,8 +1466,7 @@ func (self *LocalCommitsController) pickEnabled(selectedCommits []*models.Commit
14761466
}
14771467

14781468
if !self.isRebasing() {
1479-
// if not rebasing, we're going to do a pull so we don't care about the selection
1480-
return nil
1469+
return &types.DisabledReason{Text: self.c.Tr.PickIsOnlyAllowedDuringRebase, AllowFurtherDispatching: true}
14811470
}
14821471

14831472
return self.midRebaseCommandEnabled(selectedCommits, startIdx, endIdx)

pkg/i18n/english.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ type TranslationSet struct {
369369
RewordNotSupported string
370370
ChangingThisActionIsNotAllowed string
371371
NotAllowedMidCherryPickOrRevert string
372+
PickIsOnlyAllowedDuringRebase string
372373
DroppingMergeRequiresSingleSelection string
373374
CherryPickCopy string
374375
CherryPickCopyTooltip string
@@ -1459,6 +1460,7 @@ func EnglishTranslationSet() *TranslationSet {
14591460
RewordNotSupported: "Rewording commits while interactively rebasing is not currently supported",
14601461
ChangingThisActionIsNotAllowed: "Changing this kind of rebase todo entry is not allowed",
14611462
NotAllowedMidCherryPickOrRevert: "This action is not allowed while cherry-picking or reverting",
1463+
PickIsOnlyAllowedDuringRebase: "This action is only allowed while rebasing",
14621464
DroppingMergeRequiresSingleSelection: "Dropping a merge commit requires a single selected item",
14631465
CherryPickCopy: "Copy (cherry-pick)",
14641466
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.",

0 commit comments

Comments
 (0)