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

Cancel filter/search when hitting escape

This commit is contained in:
Jesse Duffield
2023-05-27 20:38:49 +10:00
parent a9e2c8129f
commit 84870d4503
5 changed files with 28 additions and 8 deletions

View File

@ -50,6 +50,19 @@ func (self *QuitActions) confirmQuitDuringUpdate() error {
func (self *QuitActions) Escape() error {
currentContext := self.c.CurrentContext()
switch ctx := currentContext.(type) {
case types.IFilterableContext:
if ctx.IsFiltering() {
self.c.Helpers().Search.Cancel()
return nil
}
case types.ISearchableContext:
if ctx.IsSearching() {
self.c.Helpers().Search.Cancel()
return nil
}
}
parentContext, hasParent := currentContext.GetParentContext()
if hasParent && currentContext != nil && parentContext != nil {
// TODO: think about whether this should be marked as a return rather than adding to the stack