mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
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.
This commit is contained in:
parent
3a3625d855
commit
d0d58233ff
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}}'",
|
||||
|
|
|
|||
Loading…
Reference in a new issue