1
0
mirror of https://github.com/golang/go synced 2024-11-18 18:04:46 -07:00

internal/lsp/protocol: handle cancellation delivery

$/cancelRequest is handled out of band in the Request flow, but was
allowed to continue down the Deliver chain. There's no sense in letting
downstream Handlers see it and try to reply like it was a normal
request.

Fixes golang/go#36662.

Change-Id: I8471ac0fdd4f2a08acd87d6e4b83c1f077eb8600
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215738
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Heschi Kreinick 2020-01-21 15:48:02 -05:00
parent fc669b13a2
commit b3205ff6ff

View File

@ -64,6 +64,11 @@ func (canceller) Cancel(ctx context.Context, conn *jsonrpc2.Conn, id jsonrpc2.ID
return true
}
func (canceller) Deliver(ctx context.Context, r *jsonrpc2.Request, delivered bool) bool {
// Hide cancellations from downstream handlers.
return r.Method == "$/cancelRequest"
}
func NewClient(ctx context.Context, stream jsonrpc2.Stream, client Client) (context.Context, *jsonrpc2.Conn, Server) {
ctx = WithClient(ctx, client)
conn := jsonrpc2.NewConn(stream)