1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-10-23 17:48:30 +03:00

Avoid showing <esc> in options map when it doesn't do anything

The code duplication between Escape and EscapeEnabled is unfortunate, but I
don't see a better way to solve this.
This commit is contained in:
Stefan Haller
2025-08-12 14:54:49 +02:00
parent 0af439ddf5
commit 7bf05dfca4
3 changed files with 58 additions and 7 deletions

View File

@@ -115,11 +115,12 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type
Handler: self.quitWithoutChangingDirectory,
},
{
Key: opts.GetKey(opts.Config.Universal.Return),
Modifier: gocui.ModNone,
Handler: self.escape,
Description: self.c.Tr.Cancel,
DisplayOnScreen: true,
Key: opts.GetKey(opts.Config.Universal.Return),
Modifier: gocui.ModNone,
Handler: self.escape,
Description: self.c.Tr.Cancel,
GetDisabledReason: self.escapeEnabled,
DisplayOnScreen: true,
},
{
Key: opts.GetKey(opts.Config.Universal.ToggleWhitespaceInDiffView),
@@ -190,6 +191,16 @@ func (self *GlobalController) escape() error {
return (&QuitActions{c: self.c}).Escape()
}
func (self *GlobalController) escapeEnabled() *types.DisabledReason {
if (&QuitActions{c: self.c}).EscapeEnabled() {
return nil
}
// 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: ""}
}
func (self *GlobalController) toggleWhitespace() error {
return (&ToggleWhitespaceAction{c: self.c}).Call()
}