diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-06-10 11:55:56 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-06-10 12:04:21 +0200 |
commit | d04cb9a7c583347f7bec80a6797a45cefe8224dc (patch) | |
tree | 62e7bd1cfc8fecf2664160cc1940b04ea4f9f600 | |
parent | 3da6594a433e63c5bee5836d2236839313439b2d (diff) |
fixup! Use model searching in commits (and sub-commits) viewsearch-the-model-instead-of-the-view
-rw-r--r-- | pkg/gui/controllers/helpers/search_helper.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go index 740f6d43a..2cffe418b 100644 --- a/pkg/gui/controllers/helpers/search_helper.go +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -162,10 +162,10 @@ func (self *SearchHelper) ConfirmSearch() error { return err } - return search(context) + return context.GetView().Search(searchString, modelSearchResults(context)) } -func search(context types.ISearchableContext) error { +func modelSearchResults(context types.ISearchableContext) []gocui.SearchPosition { searchString := context.GetSearchString() var normalizedSearchStr string @@ -177,7 +177,7 @@ func search(context types.ISearchableContext) error { normalizedSearchStr = strings.ToLower(searchString) } - return context.GetView().Search(searchString, context.ModelSearchResults(normalizedSearchStr, caseSensitive)) + return context.ModelSearchResults(normalizedSearchStr, caseSensitive) } func (self *SearchHelper) CancelPrompt() error { @@ -254,12 +254,12 @@ func (self *SearchHelper) ReApplySearch(ctx types.Context) { // Reapply the search if the model has changed. This is needed for contexts // that use the model for searching, to pass the new model search positions // to the view. - state := self.searchState() - if ctx == state.Context { - searchableContext, ok := ctx.(types.ISearchableContext) - if ok { - _ = search(searchableContext) + searchableContext, ok := ctx.(types.ISearchableContext) + if ok { + ctx.GetView().UpdateSearchResults(searchableContext.GetSearchString(), modelSearchResults(searchableContext)) + state := self.searchState() + if ctx == state.Context { // Re-render the "x of y" search status, unless the search prompt is // open for typing. if self.c.CurrentContext().GetKey() != context.SEARCH_CONTEXT_KEY { |