diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-05-23 08:58:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-23 08:58:19 -0700 |
commit | 109fb51589cc61696b299051f8285b84e1ff3b25 (patch) | |
tree | c27264ba109503990298f020e421c3932594fd20 /runtime/lua/vim/lsp/rpc.lua | |
parent | 3fb3b548a6c2f88e1c0c3298589e153f45e199aa (diff) | |
parent | 5d4717010c1d8065b356516a0e36503bf2b9de3d (diff) | |
download | rneovim-109fb51589cc61696b299051f8285b84e1ff3b25.tar.gz rneovim-109fb51589cc61696b299051f8285b84e1ff3b25.tar.bz2 rneovim-109fb51589cc61696b299051f8285b84e1ff3b25.zip |
Merge pull request #14622 from mfussenegger/unmute-error-responses
lsp: Only mute RequestCancelled or ContentModified, but not other errors
Diffstat (limited to 'runtime/lua/vim/lsp/rpc.lua')
-rw-r--r-- | runtime/lua/vim/lsp/rpc.lua | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index 0cabd1a0d4..98835d6708 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -523,27 +523,33 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params) decoded.error = convert_NIL(decoded.error) decoded.result = convert_NIL(decoded.result) + -- We sent a number, so we expect a number. + local result_id = tonumber(decoded.id) + -- Do not surface RequestCancelled or ContentModified to users, it is RPC-internal. if decoded.error then + local mute_error = false if decoded.error.code == protocol.ErrorCodes.RequestCancelled then local _ = log.debug() and log.debug("Received cancellation ack", decoded) + mute_error = true elseif decoded.error.code == protocol.ErrorCodes.ContentModified then local _ = log.debug() and log.debug("Received content modified ack", decoded) + mute_error = true end - 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 + + if mute_error then + -- 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 - return end - -- We sent a number, so we expect a number. - local result_id = tonumber(decoded.id) local callback = message_callbacks[result_id] if callback then message_callbacks[result_id] = nil |