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) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-08-25 09:19:02 +02:00
parent 45d68bccc2
commit a9fe055af4

View file

@ -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 {