mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-19 06:02:11 +03:00
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.
This commit is contained in:
@@ -3,6 +3,7 @@ package gui
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||||
)
|
)
|
||||||
@@ -20,6 +21,7 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
maxColumnSize := 1
|
maxColumnSize := 1
|
||||||
|
confirmKey := keybindings.GetKey(gui.c.UserConfig().Keybinding.Universal.ConfirmMenu)
|
||||||
|
|
||||||
for _, item := range opts.Items {
|
for _, item := range opts.Items {
|
||||||
if item.LabelColumns == nil {
|
if item.LabelColumns == nil {
|
||||||
@@ -31,6 +33,11 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
maxColumnSize = max(maxColumnSize, len(item.LabelColumns))
|
maxColumnSize = max(maxColumnSize, len(item.LabelColumns))
|
||||||
|
|
||||||
|
// Remove all item keybindings that are the same as the confirm binding
|
||||||
|
if item.Key == confirmKey {
|
||||||
|
item.Key = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range opts.Items {
|
for _, item := range opts.Items {
|
||||||
|
|||||||
Reference in New Issue
Block a user