From b3205ff6fffe240496f8904cf9b7ca4083aba4fd Mon Sep 17 00:00:00 2001 From: Heschi Kreinick Date: Tue, 21 Jan 2020 15:48:02 -0500 Subject: [PATCH] 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 Reviewed-by: Rebecca Stambler TryBot-Result: Gobot Gobot --- internal/lsp/protocol/protocol.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/lsp/protocol/protocol.go b/internal/lsp/protocol/protocol.go index c30e57fe02..9f950a3b80 100644 --- a/internal/lsp/protocol/protocol.go +++ b/internal/lsp/protocol/protocol.go @@ -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)