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

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.
This commit is contained in:
Sam Burville
2021-10-17 18:22:59 +01:00
committed by Jesse Duffield
parent 91e8765d9c
commit f6e316dfe5
4 changed files with 73 additions and 69 deletions

View File

@ -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() {