Bounce SuggestionsContext.SetSuggestions to UI thread

SetSuggestions has two callers: prepareConfirmationPanel calls it directly on
the UI thread, while editors.promptEditor and
SuggestionsContext.RefreshSuggestions call it via AsyncHandler, which runs the
result closure on a worker goroutine. The worker path currently relies on
HandleRender's self.c.Render() to flush the view update. Wrap the body in
OnUIThread so the worker path stays correct when Render() is removed; for the
UI-thread caller the extra bounce is harmless.
This commit is contained in:
Stefan Haller 2026-05-07 08:31:03 +02:00
parent a364a8d75c
commit 3d324ed7fb

View file

@ -67,10 +67,17 @@ func NewSuggestionsContext(
}
func (self *SuggestionsContext) SetSuggestions(suggestions []*types.Suggestion) {
self.State.Suggestions = suggestions
self.SetSelection(0)
self.c.ResetViewOrigin(self.GetView())
self.HandleRender()
// SetSuggestions is invoked from AsyncHandler (a worker goroutine) when
// the prompt input changes, as well as from prepareConfirmationPanel on
// the UI thread. Bounce to the UI thread either way so the worker path
// keeps flushing once HandleRender stops calling Render() itself.
self.c.OnUIThread(func() error {
self.State.Suggestions = suggestions
self.SetSelection(0)
self.c.ResetViewOrigin(self.GetView())
self.HandleRender()
return nil
})
}
func (self *SuggestionsContext) RefreshSuggestions() {