mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
Swap position of checkout-commit and checkout-branch menu items
Jesse's comment from https://github.com/jesseduffield/lazygit/issues/4237: We recently added a new option to check out a commit's branch from within the commits, reflog, and sub-commits panels: https://github.com/user-attachments/assets/0a5cf3f2-6803-4709-ae5a-e4addc061012 After using it for some time, I find it annoying that the default option has changed. I rarely find myself wanting to check out a branch from the commits panel, and it's rarer still to want to check out a branch from the reflog and sub-commits panel. Although there may be use cases for this, it is jarring that something you can always do (checkout the commit) is harder to do than something that you can sometimes do (checkout the branch). We've also had a user complain (see https://github.com/jesseduffield/lazygit/pull/4117) about their muscle-memory being broken by the recent change, and I have also fallen victim to this. I don't think that the new branch checkout option is sufficiently useful to dislodge the existing keybinding, so let's swap them.
This commit is contained in:
parent
190954568e
commit
e987d4b519
2 changed files with 16 additions and 14 deletions
|
@ -278,7 +278,17 @@ func (self *RefsHelper) CreateCheckoutMenu(commit *models.Commit) error {
|
|||
})
|
||||
|
||||
hash := commit.Hash
|
||||
var menuItems []*types.MenuItem
|
||||
|
||||
menuItems := []*types.MenuItem{
|
||||
{
|
||||
LabelColumns: []string{fmt.Sprintf(self.c.Tr.Actions.CheckoutCommitAsDetachedHead, utils.ShortHash(hash))},
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.CheckoutCommit)
|
||||
return self.CheckoutRef(hash, types.CheckoutRefOptions{})
|
||||
},
|
||||
Key: 'd',
|
||||
},
|
||||
}
|
||||
|
||||
if len(branches) > 0 {
|
||||
menuItems = append(menuItems, lo.Map(branches, func(branch *models.Branch, index int) *types.MenuItem {
|
||||
|
@ -304,15 +314,6 @@ func (self *RefsHelper) CreateCheckoutMenu(commit *models.Commit) error {
|
|||
})
|
||||
}
|
||||
|
||||
menuItems = append(menuItems, &types.MenuItem{
|
||||
LabelColumns: []string{fmt.Sprintf(self.c.Tr.Actions.CheckoutCommitAsDetachedHead, utils.ShortHash(hash))},
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.CheckoutCommit)
|
||||
return self.CheckoutRef(hash, types.CheckoutRefOptions{})
|
||||
},
|
||||
Key: 'd',
|
||||
})
|
||||
|
||||
return self.c.Menu(types.CreateMenuOptions{
|
||||
Title: self.c.Tr.Actions.CheckoutBranchOrCommit,
|
||||
Items: menuItems,
|
||||
|
|
|
@ -32,10 +32,11 @@ var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
|
|||
t.ExpectPopup().Menu().
|
||||
Title(Contains("Checkout branch or commit")).
|
||||
Lines(
|
||||
Contains("Checkout branch").IsSelected(),
|
||||
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head"),
|
||||
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head").IsSelected(),
|
||||
Contains("Checkout branch"),
|
||||
Contains("Cancel"),
|
||||
).
|
||||
Select(Contains("Checkout branch")).
|
||||
Tooltip(Contains("Disabled: No branches found at selected commit.")).
|
||||
Select(MatchesRegexp("Checkout commit [a-f0-9]+ as detached head")).
|
||||
Confirm()
|
||||
|
@ -53,9 +54,9 @@ var Checkout = NewIntegrationTest(NewIntegrationTestArgs{
|
|||
t.ExpectPopup().Menu().
|
||||
Title(Contains("Checkout branch or commit")).
|
||||
Lines(
|
||||
Contains("Checkout branch 'branch1'").IsSelected(),
|
||||
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head").IsSelected(),
|
||||
Contains("Checkout branch 'branch1'"),
|
||||
Contains("Checkout branch 'master'"),
|
||||
MatchesRegexp("Checkout commit [a-f0-9]+ as detached head"),
|
||||
Contains("Cancel"),
|
||||
).
|
||||
Select(Contains("Checkout branch 'master'")).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue