mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Don't allow opening a menu while the search or filter prompt is open
This solves several problems that arise from opening a menu while the prompt is open. We might try to solve these in a different way, e.g. by dismissing the search prompt before opening a menu, but restricting what you can do while the prompt is open seems like the more robust fix. To achieve this, we - call resetKeyBindings both when opening and when closing the search/filter prompt - change the keybindings to only contain the ones for the search prompt when that context is active.
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
@ -345,6 +346,18 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
|
||||
}
|
||||
|
||||
func (self *Gui) GetInitialKeybindingsWithCustomCommands() ([]*types.Binding, []*gocui.ViewMouseBinding) {
|
||||
// if the search or filter prompt is open, we only want the keybindings for
|
||||
// that context. It shouldn't be possible, for example, to open a menu while
|
||||
// the prompt is showing; you first need to confirm or cancel the search/filter.
|
||||
if currentContext := self.State.ContextMgr.Current(); currentContext.GetKey() == context.SEARCH_CONTEXT_KEY {
|
||||
bindings := currentContext.GetKeybindings(self.c.KeybindingsOpts())
|
||||
viewName := currentContext.GetViewName()
|
||||
for _, binding := range bindings {
|
||||
binding.ViewName = viewName
|
||||
}
|
||||
return bindings, nil
|
||||
}
|
||||
|
||||
bindings, mouseBindings := self.GetInitialKeybindings()
|
||||
customBindings, err := self.CustomCommandsClient.GetCustomCommandKeybindings()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user