From f3bc6fc85e1526d27a58229cf06a3d5029730f23 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 12 Nov 2026 09:10:17 +0100 Subject: [PATCH] Extract what the prompt and menu filter editors do after an edit Handlers for pasted text are going to need the same steps. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/editors.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/gui/editors.go b/pkg/gui/editors.go index 7c658265b..35d7adaac 100644 --- a/pkg/gui/editors.go +++ b/pkg/gui/editors.go @@ -33,7 +33,12 @@ func (gui *Gui) promptEditor(v *gocui.View, key gocui.Key) bool { matched := gui.handleEditorKeypress(v, key, false) v.RenderTextArea() + gui.onPromptContentChanged(v) + return matched +} + +func (gui *Gui) onPromptContentChanged(v *gocui.View) { suggestionsContext := gui.State.Contexts.Suggestions // Capture the suggestions function and the input here, on the UI thread; the // main thread rewrites State.FindSuggestions when it (re)creates a prompt @@ -45,8 +50,6 @@ func (gui *Gui) promptEditor(v *gocui.View, key gocui.Key) bool { return func() { suggestionsContext.SetSuggestions(suggestions) } }) } - - return matched } func (gui *Gui) menuFilterEditor(v *gocui.View, key gocui.Key) bool { @@ -68,11 +71,15 @@ func (gui *Gui) menuFilterEditor(v *gocui.View, key gocui.Key) bool { return true } + gui.onMenuFilterContentChanged(content) + + return true +} + +func (gui *Gui) onMenuFilterContentChanged(content string) { menuContext := gui.State.Contexts.Menu menuContext.SetFilterStarted(true) gui.helpers.Search.ApplyFilter(menuContext, content) - - return true } func (gui *Gui) searchEditor(v *gocui.View, key gocui.Key) bool {