mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Cleanup: restructure code for clarity
There was no reason to declare a variable for disabledReason, assign it inside the "if binding.GetDisabledReason != nil" statement, and then check its value again after that if statement. Move all that code inside the first if statement to make the control flow easier to understand.
This commit is contained in:
parent
9e64f7dd66
commit
37b118f4fb
|
|
@ -523,19 +523,18 @@ func (gui *Gui) SetMouseKeybinding(binding *gocui.ViewMouseBinding) error {
|
|||
}
|
||||
|
||||
func (gui *Gui) callKeybindingHandler(binding *types.Binding) error {
|
||||
var disabledReason *types.DisabledReason
|
||||
if binding.GetDisabledReason != nil {
|
||||
disabledReason = binding.GetDisabledReason()
|
||||
}
|
||||
if disabledReason != nil {
|
||||
if disabledReason.ShowErrorInPanel {
|
||||
return errors.New(disabledReason.Text)
|
||||
}
|
||||
if disabledReason := binding.GetDisabledReason(); disabledReason != nil {
|
||||
if disabledReason.ShowErrorInPanel {
|
||||
return errors.New(disabledReason.Text)
|
||||
}
|
||||
|
||||
if len(disabledReason.Text) > 0 {
|
||||
gui.c.ErrorToast(gui.Tr.DisabledMenuItemPrefix + disabledReason.Text)
|
||||
if len(disabledReason.Text) > 0 {
|
||||
gui.c.ErrorToast(gui.Tr.DisabledMenuItemPrefix + disabledReason.Text)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return binding.Handler()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue