diff options
Diffstat (limited to 'runtime/lua/vim/lsp/rpc.lua')
| -rw-r--r-- | runtime/lua/vim/lsp/rpc.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index 1cc5ffef44..761c0aac17 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -380,7 +380,9 @@ function Client:handle_body(body) if type(decoded) ~= 'table' then self:on_error(M.client_errors.INVALID_SERVER_MESSAGE, decoded) - elseif type(decoded.method) == 'string' and decoded.id then + elseif type(decoded.method) == 'string' and decoded.id and decoded.id ~= vim.NIL then + local id_type = type(decoded.id) + assert(id_type == 'number' or id_type == 'string', 'Request id must be a number or a string') local err --- @type lsp.ResponseError? -- Schedule here so that the users functions don't trigger an error and -- we can still use the result. @@ -426,6 +428,7 @@ function Client:handle_body(body) -- - If 'result' is nil, then 'error' must be present (and not vim.NIL). elseif decoded.id + and decoded.id ~= vim.NIL and ( (decoded.error == nil and decoded.result ~= nil) or (decoded.result == nil and decoded.error ~= nil and decoded.error ~= vim.NIL) @@ -477,6 +480,9 @@ function Client:handle_body(body) self:on_error(M.client_errors.NO_RESULT_CALLBACK_FOUND, decoded) log.error('No callback found for server response id ' .. result_id) end + elseif decoded.id == vim.NIL then + log.warn('Server sent response with null id', decoded.error) + self:on_error(M.client_errors.INVALID_SERVER_MESSAGE, decoded) elseif type(decoded.method) == 'string' then -- Notification self:try_call( |
