summaryrefslogtreecommitdiffstats
path: root/pkg/gui/keybindings.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-02-13 10:39:14 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commit3188526ecb1e48327249a830173de7ab5ce5978a (patch)
tree559223336c868f2553057fb1cdeaf0d6e2600df7 /pkg/gui/keybindings.go
parent722410aded4e3d14356c7ab94bfa15abe10359fa (diff)
fix cheatsheet crash
Diffstat (limited to 'pkg/gui/keybindings.go')
-rw-r--r--pkg/gui/keybindings.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 25433eca5..a2dd7a419 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -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