From d0d58233fffe9ff18621664b53a0e05ee604df9e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 17 May 2026 15:40:13 +0200 Subject: [PATCH] If a menu entry has multiple keybindings, list them in a tooltip We append them with a blank line to an existing tooltip if the item already has one, or create a new tooltip if not. --- pkg/gui/controllers/options_menu_action.go | 14 +++++++++++++- pkg/i18n/english.go | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/gui/controllers/options_menu_action.go b/pkg/gui/controllers/options_menu_action.go index e49c02386..c92fdd589 100644 --- a/pkg/gui/controllers/options_menu_action.go +++ b/pkg/gui/controllers/options_menu_action.go @@ -1,6 +1,10 @@ package controllers import ( + "strings" + + "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" @@ -23,6 +27,14 @@ func (self *OptionsMenuAction) Call() error { if binding.GetDisabledReason != nil { disabledReason = binding.GetDisabledReason() } + tooltip := binding.Tooltip + if len(binding.Keys) > 1 { + if tooltip != "" { + tooltip += "\n\n" + } + keyLabels := lo.Map(binding.Keys, func(k gocui.Key, _ int) string { return config.LabelForKey(k) }) + tooltip += self.c.Tr.KeybindingsTooltip + strings.Join(keyLabels, ", ") + } return &types.MenuItem{ OpensMenu: binding.OpensMenu, Label: binding.GetDescription(), @@ -34,7 +46,7 @@ func (self *OptionsMenuAction) Call() error { return self.c.IGuiCommon.CallKeybindingHandler(binding) }, Keys: binding.Keys, - Tooltip: binding.Tooltip, + Tooltip: tooltip, DisabledReason: disabledReason, Section: section, } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 769248375..ee5f4ceec 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -616,6 +616,7 @@ type TranslationSet struct { KeybindingsMenuSectionLocal string KeybindingsMenuSectionGlobal string KeybindingsMenuSectionNavigation string + KeybindingsTooltip string RenameBranch string Upstream string BranchUpstreamOptionsTitle string @@ -1475,6 +1476,7 @@ func EnglishTranslationSet() *TranslationSet { KeybindingsMenuSectionLocal: "Local", KeybindingsMenuSectionGlobal: "Global", KeybindingsMenuSectionNavigation: "Navigation", + KeybindingsTooltip: "Keybindings: ", RebasingTitle: "Rebase '{{.checkedOutBranch}}'", RebasingFromBaseCommitTitle: "Rebase '{{.checkedOutBranch}}' from marked base", SimpleRebase: "Simple rebase onto '{{.ref}}'",