mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +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:
@ -45,7 +45,7 @@ func (self *SearchHelper) OpenFilterPrompt(context types.IFilterableContext) err
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return self.c.ResetKeybindings()
|
||||
}
|
||||
|
||||
func (self *SearchHelper) OpenSearchPrompt(context types.ISearchableContext) error {
|
||||
@ -64,7 +64,7 @@ func (self *SearchHelper) OpenSearchPrompt(context types.ISearchableContext) err
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return self.c.ResetKeybindings()
|
||||
}
|
||||
|
||||
func (self *SearchHelper) DisplayFilterStatus(context types.IFilterableContext) {
|
||||
@ -112,16 +112,21 @@ func (self *SearchHelper) Confirm() error {
|
||||
return self.CancelPrompt()
|
||||
}
|
||||
|
||||
var err error
|
||||
switch state.SearchType() {
|
||||
case types.SearchTypeFilter:
|
||||
return self.ConfirmFilter()
|
||||
err = self.ConfirmFilter()
|
||||
case types.SearchTypeSearch:
|
||||
return self.ConfirmSearch()
|
||||
err = self.ConfirmSearch()
|
||||
case types.SearchTypeNone:
|
||||
return self.c.Context().Pop()
|
||||
err = self.c.Context().Pop()
|
||||
}
|
||||
|
||||
return nil
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.ResetKeybindings()
|
||||
}
|
||||
|
||||
func (self *SearchHelper) ConfirmFilter() error {
|
||||
@ -183,7 +188,11 @@ func modelSearchResults(context types.ISearchableContext) []gocui.SearchPosition
|
||||
func (self *SearchHelper) CancelPrompt() error {
|
||||
self.Cancel()
|
||||
|
||||
return self.c.Context().Pop()
|
||||
if err := self.c.Context().Pop(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.ResetKeybindings()
|
||||
}
|
||||
|
||||
func (self *SearchHelper) ScrollHistory(scrollIncrement int) {
|
||||
|
Reference in New Issue
Block a user