summaryrefslogtreecommitdiff
path: root/internal/lsp/handlers_document.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-23 09:04:17 +0200
committerPaul Buetow <paul@buetow.org>2026-03-23 09:04:17 +0200
commit462184dff3eef32f01f06634305da1355ac1bec2 (patch)
tree026ffaaeacfe152957298c985e1df77ff661b723 /internal/lsp/handlers_document.go
parent667f2d3384643aa877de2eefcbad3923965bad09 (diff)
chore: bump version to v0.25.9v0.25.9
Code quality fixes from audit: - Log silently discarded errors in status sinks and stats.Update call sites - Fix json.Marshal errors silently ignored in LSP handlers - Replace time.Sleep in tests with channel signaling (mcp) and fake clock (stats) - Make context cancellation work in production time.Sleep sites (handlers_document, cmdentry) - Remove init()-based provider registration from llm package; use explicit RegisterAllProviders() - Add WaitGroup goroutine tracking to MCP server Run() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/lsp/handlers_document.go')
-rw-r--r--internal/lsp/handlers_document.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/internal/lsp/handlers_document.go b/internal/lsp/handlers_document.go
index f69c626..7c59aa8 100644
--- a/internal/lsp/handlers_document.go
+++ b/internal/lsp/handlers_document.go
@@ -2,6 +2,7 @@
package lsp
import (
+ "context"
"encoding/json"
"strings"
"time"
@@ -400,9 +401,13 @@ func (s *Server) buildChatMessages(uri string, pos Position, prompt string) []ll
// clientApplyEdit sends a workspace/applyEdit request to the client.
func (s *Server) clientApplyEdit(label string, edit WorkspaceEdit) {
params := ApplyWorkspaceEditParams{Label: label, Edit: edit}
+ b, err := json.Marshal(params)
+ if err != nil {
+ logging.Logf("lsp ", "clientApplyEdit: marshal error: %v", err)
+ return
+ }
id := s.nextReqID()
req := Request{JSONRPC: "2.0", ID: id, Method: "workspace/applyEdit"}
- b, _ := json.Marshal(params)
req.Params = b
s.writeMessage(req)
}
@@ -428,9 +433,13 @@ func (s *Server) clientShowDocument(uri string, sel *Range) {
params.URI = uri
params.TakeFocus = true
params.Selection = sel
+ b, err := json.Marshal(params)
+ if err != nil {
+ logging.Logf("lsp ", "clientShowDocument: marshal error: %v", err)
+ return
+ }
id := s.nextReqID()
req := Request{JSONRPC: "2.0", ID: id, Method: "window/showDocument"}
- b, _ := json.Marshal(params)
req.Params = b
s.writeMessage(req)
}
@@ -440,14 +449,13 @@ func (s *Server) clientShowDocument(uri string, sel *Range) {
// The goroutine respects s.serverCtx so it won't write after shutdown.
func (s *Server) deferShowDocument(uri string, sel Range) {
ctx := s.serverCtx
+ if ctx == nil {
+ // Fallback for tests that don't set a server context.
+ ctx = context.Background()
+ }
s.inflight.Add(1)
go func() {
defer s.inflight.Done()
- if ctx == nil {
- time.Sleep(120 * time.Millisecond)
- s.clientShowDocument(uri, &sel)
- return
- }
select {
case <-time.After(120 * time.Millisecond):
s.clientShowDocument(uri, &sel)