diff options
Diffstat (limited to 'internal/lsp/handlers_completion.go')
| -rw-r--r-- | internal/lsp/handlers_completion.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/lsp/handlers_completion.go b/internal/lsp/handlers_completion.go index aa22fc2..527d020 100644 --- a/internal/lsp/handlers_completion.go +++ b/internal/lsp/handlers_completion.go @@ -216,7 +216,13 @@ func collectCompletionResults(results <-chan completionJobResult) []CompletionIt func (s *Server) firstCompletionAndStore(results <-chan completionJobResult, cacheKey string, end func()) ([]CompletionItem, bool) { firstCh := make(chan []CompletionItem, 1) - go s.collectFirstCompletion(results, cacheKey, firstCh, end) + // Track this goroutine in inflight so Run's deferred Wait() catches it + // and prevents use-after-close writes on shutdown. + s.inflight.Add(1) + go func() { + defer s.inflight.Done() + s.collectFirstCompletion(results, cacheKey, firstCh, end) + }() firstItems, ok := <-firstCh if !ok || len(firstItems) == 0 { return nil, false |
