Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ All notable changes to the Docker Language Server will be documented in this fil

### Fixed

- Dockerfile
- textDocument/inlayHint
- handle inlay hints asynchronously so that it does not block other LSP messages when trying to fetch image data ([#467](https://github.com/docker/docker-language-server/issues/467))
- Compose
- textDocument/documentLink
- return document links for files referenced in the short-form `volumes` attribute of a service object ([#460](https://github.com/docker/docker-language-server/issues/460))
Expand Down
23 changes: 22 additions & 1 deletion internal/tliron/glsp/server/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,34 @@ import (
"fmt"

"github.com/docker/docker-language-server/internal/tliron/glsp"
"github.com/docker/docker-language-server/internal/tliron/glsp/protocol"
"github.com/sourcegraph/jsonrpc2"
)

// AsynchronousRequestHandler will selectively process some JSON-RPC
// messages asynchronously.
type AsynchronousRequestHandler struct {
handler jsonrpc2.Handler
}

func asynchronousRequest(req *jsonrpc2.Request) bool {
// handle textDocument/inlayHint requests asynchronously
return !req.Notif && req.Method == protocol.MethodTextDocumentInlayHint
}

func (h *AsynchronousRequestHandler) Handle(ctx contextpkg.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) {
if asynchronousRequest(req) {
go h.handler.Handle(ctx, conn, req)
} else {
// handle notifications synchronously so that the document changes do not overlap each other
h.handler.Handle(ctx, conn, req)
}
}

// See: https://github.com/sourcegraph/go-langserver/blob/master/langserver/handler.go#L206

func (self *Server) newHandler() jsonrpc2.Handler {
return jsonrpc2.HandlerWithError(self.handle)
return &AsynchronousRequestHandler{handler: jsonrpc2.HandlerWithError(self.handle)}
}

func (self *Server) handle(context contextpkg.Context, connection *jsonrpc2.Conn, request *jsonrpc2.Request) (any, error) {
Expand Down
Loading