diff options
author | Ashkan Kiani <ashkan.k.kiani@gmail.com> | 2019-12-24 14:28:09 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-24 14:28:09 -0800 |
commit | 07a2260e1d5fa8c7c4e2ec1ff8679a120fe399e8 (patch) | |
tree | 850ac3bf2c46af07bd3d2f1904d9a8f5d23df49d /runtime/lua/vim/lsp/rpc.lua | |
parent | 34abe8fd23e7760fff4824c08dd8ee7eb4f7dd67 (diff) | |
download | rneovim-07a2260e1d5fa8c7c4e2ec1ff8679a120fe399e8.tar.gz rneovim-07a2260e1d5fa8c7c4e2ec1ff8679a120fe399e8.tar.bz2 rneovim-07a2260e1d5fa8c7c4e2ec1ff8679a120fe399e8.zip |
LSP: Handle rpc RequestCancelled specifically. (#11606)
This was creating extra noise in errors that we should've been handling
internally.
Fixes #11515
Diffstat (limited to 'runtime/lua/vim/lsp/rpc.lua')
-rw-r--r-- | runtime/lua/vim/lsp/rpc.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index a558f66a42..72a0bf8d6f 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -1,3 +1,4 @@ +local vim = vim local uv = vim.loop local log = require('vim.lsp.log') local protocol = require('vim.lsp.protocol') @@ -377,6 +378,22 @@ local function create_and_start_client(cmd, cmd_args, handlers, extra_spawn_para decoded.error = convert_NIL(decoded.error) decoded.result = convert_NIL(decoded.result) + -- Do not surface RequestCancelled to users, it is RPC-internal. + if decoded.error + and decoded.error.code == protocol.ErrorCodes.RequestCancelled then + local _ = log.debug() and log.debug("Received cancellation ack", decoded) + local result_id = tonumber(decoded.id) + -- Clear any callback since this is cancelled now. + -- This is safe to do assuming that these conditions hold: + -- - The server will not send a result callback after this cancellation. + -- - If the server sent this cancellation ACK after sending the result, the user of this RPC + -- client will ignore the result themselves. + if result_id then + message_callbacks[result_id] = nil + end + return + end + -- We sent a number, so we expect a number. local result_id = tonumber(decoded.id) local callback = message_callbacks[result_id] |