From a9fe055af4e7b502de3b05a1fee57b1e5f11a4a8 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 25 Aug 2026 09:19:02 +0200 Subject: [PATCH] Extract applying a filter to a context A filter can come from somewhere other than the search prompt: a menu that filters as you type has its own input field, and needs to apply what is typed there without going through the prompt's state. Co-authored-by: Claude Opus 5 (1M context) --- pkg/gui/controllers/helpers/search_helper.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go index b0b948292..5de08df6d 100644 --- a/pkg/gui/controllers/helpers/search_helper.go +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -225,9 +225,7 @@ func (self *SearchHelper) OnPromptContentChanged(searchString string) { state := self.searchState() switch context := state.Context.(type) { case types.IFilterableContext: - context.SetSelection(0) - context.SetFilter(searchString, self.c.UserConfig().Gui.UseFuzzySearch()) - self.c.PostRefreshUpdate(context) + self.ApplyFilter(context, searchString) case types.ISearchableContext: // do nothing default: @@ -235,6 +233,12 @@ func (self *SearchHelper) OnPromptContentChanged(searchString string) { } } +func (self *SearchHelper) ApplyFilter(context types.IFilterableContext, filter string) { + context.SetSelection(0) + context.SetFilter(filter, self.c.UserConfig().Gui.UseFuzzySearch()) + self.c.PostRefreshUpdate(context) +} + func (self *SearchHelper) ReApplyFilter(context types.Context) { filterableContext, ok := context.(types.IFilterableContext) if ok {