diff options
author | Sam Burville <Sam.Burville@GlobalProcessing.com> | 2021-10-17 18:22:59 +0100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-22 22:38:26 +1100 |
commit | f6e316dfe5a35696e091f760e533a7a62f946f99 (patch) | |
tree | 2a9431d543b47ff4c74e9a9d3ccf74d6b755813c /pkg/gui/keybindings.go | |
parent | 91e8765d9ca04aa88377f07d8abe665fb8fc66fe (diff) |
Improve JumpToBlock keybinding functionality
Improve experience when yaml file has != 5 keybindings and change view
helper to use the length of the array instead of hardcoded value.
Diffstat (limited to 'pkg/gui/keybindings.go')
-rw-r--r-- | pkg/gui/keybindings.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 1678ee03c..76a33a33a 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -1818,12 +1818,16 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { } // Appends keybindings to jump to a particular sideView using numbers - for i, window := range []string{"status", "files", "branches", "commits", "stash"} { - bindings = append(bindings, &Binding{ - ViewName: "", - Key: gui.getKey(config.Universal.JumpToBlock[i]), - Modifier: gocui.ModNone, - Handler: gui.goToSideWindow(window)}) + if len(config.Universal.JumpToBlock) != 5 { + log.Fatal("Jump to block keybindings cannot be set. Exactly 5 keybindings must be supplied.") + } else { + for i, window := range []string{"status", "files", "branches", "commits", "stash"} { + bindings = append(bindings, &Binding{ + ViewName: "", + Key: gui.getKey(config.Universal.JumpToBlock[i]), + Modifier: gocui.ModNone, + Handler: gui.goToSideWindow(window)}) + } } for viewName := range gui.State.Contexts.initialViewTabContextMap() { |