mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 04:45:47 +02:00
Disable KeybindingsMenu using a DisabledReason when a panel is open
This hides it from the options map at the bottom of the screen.
This commit is contained in:
parent
9de8d17d84
commit
928e76a82f
2 changed files with 16 additions and 9 deletions
|
@ -69,10 +69,11 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
// we have the description on the alt key and not the main key for legacy reasons
|
// we have the description on the alt key and not the main key for legacy reasons
|
||||||
// (the original main key was 'x' but we've reassigned that to other purposes)
|
// (the original main key was 'x' but we've reassigned that to other purposes)
|
||||||
Description: self.c.Tr.OpenKeybindingsMenu,
|
Description: self.c.Tr.OpenKeybindingsMenu,
|
||||||
Handler: self.createOptionsMenu,
|
Handler: self.createOptionsMenu,
|
||||||
ShortDescription: self.c.Tr.Keybindings,
|
ShortDescription: self.c.Tr.Keybindings,
|
||||||
DisplayOnScreen: true,
|
DisplayOnScreen: true,
|
||||||
|
GetDisabledReason: self.optionsMenuDisabledReason,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewName: "",
|
ViewName: "",
|
||||||
|
@ -156,6 +157,17 @@ func (self *GlobalController) createOptionsMenu() error {
|
||||||
return (&OptionsMenuAction{c: self.c}).Call()
|
return (&OptionsMenuAction{c: self.c}).Call()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *GlobalController) optionsMenuDisabledReason() *types.DisabledReason {
|
||||||
|
ctx := self.c.Context().Current()
|
||||||
|
// Don't show options menu while displaying popup.
|
||||||
|
if ctx.GetKind() == types.PERSISTENT_POPUP || ctx.GetKind() == types.TEMPORARY_POPUP {
|
||||||
|
// The empty error text is intentional. We don't want to show an error
|
||||||
|
// toast for this, but only hide it from the options map.
|
||||||
|
return &types.DisabledReason{Text: ""}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (self *GlobalController) createFilteringMenu() error {
|
func (self *GlobalController) createFilteringMenu() error {
|
||||||
return (&FilteringMenuAction{c: self.c}).Call()
|
return (&FilteringMenuAction{c: self.c}).Call()
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,6 @@ type OptionsMenuAction struct {
|
||||||
|
|
||||||
func (self *OptionsMenuAction) Call() error {
|
func (self *OptionsMenuAction) Call() error {
|
||||||
ctx := self.c.Context().Current()
|
ctx := self.c.Context().Current()
|
||||||
// Don't show menu while displaying popup.
|
|
||||||
if ctx.GetKind() == types.PERSISTENT_POPUP || ctx.GetKind() == types.TEMPORARY_POPUP {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
local, global, navigation := self.getBindings(ctx)
|
local, global, navigation := self.getBindings(ctx)
|
||||||
|
|
||||||
menuItems := []*types.MenuItem{}
|
menuItems := []*types.MenuItem{}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue