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

fix cheatsheet crash

This commit is contained in:
Jesse Duffield
2022-02-13 10:39:14 +11:00
parent 722410aded
commit 3188526ecb
7 changed files with 66 additions and 42 deletions

View File

@ -10,6 +10,7 @@ import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/constants"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
@ -194,6 +195,16 @@ func (gui *Gui) noPopupPanel(f func() error) func() error {
}
}
// only to be called from the cheatsheet generate script. This mutates the Gui struct.
func (self *Gui) GetCheatsheetKeybindings() []*types.Binding {
self.helpers = helpers.NewStubHelpers()
self.State = &GuiRepoState{}
self.State.Contexts = self.contextTree()
self.resetControllers()
bindings, _ := self.GetInitialKeybindings()
return bindings
}
// renaming receiver to 'self' to aid refactoring. Will probably end up moving all Gui handlers to this pattern eventually.
func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBinding) {
config := self.c.UserConfig.Keybinding
@ -1306,8 +1317,6 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
func (gui *Gui) resetKeybindings() error {
gui.g.DeleteAllKeybindings()
bindings := gui.GetCustomCommandKeybindings()
bindings, mouseBindings := gui.GetInitialKeybindings()
// prepending because we want to give our custom keybindings precedence over default keybindings