summaryrefslogtreecommitdiffstats
path: root/pkg/gui/context.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-06-03 13:15:41 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-03 12:54:14 +1000
commit13c1103815e791966615647726000f2e3a7de828 (patch)
tree914a71f6c21ac3f36b148ea7285de8b6d98acf2a /pkg/gui/context.go
parentb8bee4de5158a6f285127eff018c442bf45ae970 (diff)
Only cancel search if main or temporary context loses focus
This is a pickle: initially I wanted it so that a filter would cancel automatically if the current context lost focus. But there are situations where you want to retain the focus, e.g. when a popup appears, or when you view the commits of a branch. The issue is that when you view the commits of a branch, the branches context is removed from the context stack. Even if this were not the case, you could imagine going branches -> sub-commits -> files -> sub-commits, where in that case branches would definitely be off the stack upon navigating to the files context. So because I'm too lazy to find a proper solution to this problem, I'm just making it so that filters in side contexts are retained unless explicitly cancelled. There's another edge case this commit handles which is that if I'm in the sub-commits context via the branches context and start a search, then navigate to the reflog context and hit enter to get to the sub-commits context again, I need to cancel the search before I switch. Likewise with the commit files context.
Diffstat (limited to 'pkg/gui/context.go')
-rw-r--r--pkg/gui/context.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index 1c235a93f..e9a15870b 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -201,7 +201,10 @@ func (self *ContextMgr) deactivateContext(c types.Context, opts types.OnFocusLos
view, _ := self.gui.c.GocuiGui().View(c.GetViewName())
if opts.NewContextKey != context.SEARCH_CONTEXT_KEY {
- self.gui.helpers.Search.CancelSearchIfSearching(c)
+ self.gui.helpers.Search.HidePrompt()
+ if c.GetKind() == types.MAIN_CONTEXT || c.GetKind() == types.TEMPORARY_POPUP {
+ self.gui.helpers.Search.CancelSearchIfSearching(c)
+ }
}
// if we are the kind of context that is sent to back upon deactivation, we should do that