Skip to content

Commit fb8a191

Browse files
stefanhallerkarolzwolak
authored andcommitted
Remove keybindings for menu items that are the same as the menu confirm key
This is needed when remapping the confirmMenu key to, say, "y", and there's a menu that has an item with a "y" binding. This already worked correctly (confirm takes precedence, as desired), but it's still confusing to see the item binding.
1 parent 927dc9d commit fb8a191

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/gui/menu_panel.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package gui
33
import (
44
"fmt"
55

6+
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
67
"github.com/jesseduffield/lazygit/pkg/gui/types"
78
"github.com/jesseduffield/lazygit/pkg/theme"
89
)
@@ -20,6 +21,7 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
2021
}
2122

2223
maxColumnSize := 1
24+
confirmKey := keybindings.GetKey(gui.c.UserConfig().Keybinding.Universal.ConfirmMenu)
2325

2426
for _, item := range opts.Items {
2527
if item.LabelColumns == nil {
@@ -31,6 +33,11 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
3133
}
3234

3335
maxColumnSize = max(maxColumnSize, len(item.LabelColumns))
36+
37+
// Remove all item keybindings that are the same as the confirm binding
38+
if item.Key == confirmKey {
39+
item.Key = nil
40+
}
3441
}
3542

3643
for _, item := range opts.Items {

0 commit comments

Comments
 (0)