1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-05-21 22:43:27 +02:00

better handling of global custom keybindings

This commit is contained in:
Jesse Duffield 2020-09-27 11:04:57 +10:00
parent 4dad7064cc
commit 12f9b1416f
2 changed files with 4 additions and 2 deletions

View File

@ -212,6 +212,7 @@ func (gui *Gui) GetCustomCommandKeybindings() []*Binding {
for _, customCommand := range customCommands {
var viewName string
var contexts []string
switch customCommand.Context {
case "global":
viewName = ""
@ -226,11 +227,12 @@ func (gui *Gui) GetCustomCommandKeybindings() []*Binding {
// Currently this is a safe bet but it's by no means guaranteed in the long term
// and we might need to make some changes in the future to support it.
viewName = context.GetViewName()
contexts = []string{customCommand.Context}
}
bindings = append(bindings, &Binding{
ViewName: viewName,
Contexts: []string{customCommand.Context},
Contexts: contexts,
Key: gui.getKey(customCommand.Key),
Modifier: gocui.ModNone,
Handler: gui.wrappedHandler(gui.handleCustomCommandKeybinding(customCommand)),

View File

@ -12,7 +12,7 @@ func (gui *Gui) getBindings(v *gocui.View) []*Binding {
bindingsGlobal, bindingsPanel []*Binding
)
bindings := append(gui.GetInitialKeybindings(), gui.GetCustomCommandKeybindings()...)
bindings := append(gui.GetCustomCommandKeybindings(), gui.GetInitialKeybindings()...)
for _, binding := range bindings {
if GetKeyDisplay(binding.Key) != "" && binding.Description != "" {