diff options
Diffstat (limited to 'internal/lsp')
| -rw-r--r-- | internal/lsp/handlers_completion.go | 8 | ||||
| -rw-r--r-- | internal/lsp/transport.go | 2 |
2 files changed, 8 insertions, 2 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 diff --git a/internal/lsp/transport.go b/internal/lsp/transport.go index bca2c37..3547dfa 100644 --- a/internal/lsp/transport.go +++ b/internal/lsp/transport.go @@ -33,7 +33,7 @@ func (s *Server) readMessage() ([]byte, error) { case "content-length": n, err := strconv.Atoi(val) if err != nil { - return nil, fmt.Errorf("invalid Content-Length: %v", err) + return nil, fmt.Errorf("invalid Content-Length: %w", err) } contentLength = n } |
