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 diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go index 68af20b35..294ce9dbf 100644 --- a/pkg/gui/controllers/helpers/search_helper.go +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -41,15 +41,16 @@ func (self *SearchHelper) OpenFilterPrompt(context types.IFilterableContext) err return nil } -func (self *SearchHelper) OpenSearchPrompt(context types.Context) error { +func (self *SearchHelper) OpenSearchPrompt(context types.ISearchableContext) error { state := self.searchState() state.Context = context + searchString := context.GetSearchString() self.searchPrefixView().SetContent(self.c.Tr.SearchPrefix) promptView := self.promptView() - // TODO: should we show the currently searched thing here? Perhaps we can store that on the context promptView.ClearTextArea() + promptView.TextArea.TypeString(searchString) promptView.RenderTextArea() if err := self.c.PushContext(self.c.Contexts().Search); err != nil { @@ -78,7 +79,8 @@ func (self *SearchHelper) DisplaySearchPrompt(context types.ISearchableContext) state.Context = context searchString := context.GetSearchString() - self.searchPrefixView().SetContent(self.c.Tr.SearchPrefix) + _ = context.GetView().SelectCurrentSearchResult() + promptView := self.promptView() promptView.ClearTextArea() promptView.TextArea.TypeString(searchString) @@ -179,7 +181,7 @@ func (self *SearchHelper) Cancel() { // do nothing } - state.Context = nil + self.HidePrompt() } func (self *SearchHelper) OnPromptContentChanged(searchString string) { @@ -229,3 +231,8 @@ func (self *SearchHelper) CancelSearchIfSearching(c types.Context) { return } } + +func (self *SearchHelper) HidePrompt() { + state := self.searchState() + state.Context = nil +} diff --git a/pkg/gui/controllers/switch_to_diff_files_controller.go b/pkg/gui/controllers/switch_to_diff_files_controller.go index ffec6936e..767520d20 100644 --- a/pkg/gui/controllers/switch_to_diff_files_controller.go +++ b/pkg/gui/controllers/switch_to_diff_files_controller.go @@ -83,6 +83,7 @@ func (self *SwitchToDiffFilesController) viewFiles(opts SwitchToCommitFilesConte diffFilesContext.SetCanRebase(opts.CanRebase) diffFilesContext.SetParentContext(opts.Context) diffFilesContext.SetWindowName(opts.Context.GetWindowName()) + diffFilesContext.ClearFilter() if err := self.c.Refresh(types.RefreshOptions{ Scope: []types.RefreshableView{types.COMMIT_FILES}, diff --git a/pkg/gui/controllers/switch_to_sub_commits_controller.go b/pkg/gui/controllers/switch_to_sub_commits_controller.go index 5ae86f02b..8163181e5 100644 --- a/pkg/gui/controllers/switch_to_sub_commits_controller.go +++ b/pkg/gui/controllers/switch_to_sub_commits_controller.go @@ -71,12 +71,15 @@ func (self *SwitchToSubCommitsController) viewCommits() error { self.setSubCommits(commits) - self.c.Contexts().SubCommits.SetSelectedLineIdx(0) - self.c.Contexts().SubCommits.SetParentContext(self.context) - self.c.Contexts().SubCommits.SetWindowName(self.context.GetWindowName()) - self.c.Contexts().SubCommits.SetTitleRef(ref.Description()) - self.c.Contexts().SubCommits.SetRef(ref) - self.c.Contexts().SubCommits.SetLimitCommits(true) + subCommitsContext := self.c.Contexts().SubCommits + subCommitsContext.SetSelectedLineIdx(0) + subCommitsContext.SetParentContext(self.context) + subCommitsContext.SetWindowName(self.context.GetWindowName()) + subCommitsContext.SetTitleRef(ref.Description()) + subCommitsContext.SetRef(ref) + subCommitsContext.SetLimitCommits(true) + subCommitsContext.ClearSearchString() + subCommitsContext.GetView().ClearSearch() err = self.c.PostRefreshUpdate(self.c.Contexts().SubCommits) if err != nil {