mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-11 08:06:25 -04:00
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:
parent
a364a8d75c
commit
3d324ed7fb
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue