aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorTama McGlinn <t.mcglinn@gmail.com>2024-06-14 11:02:36 +0200
committerGitHub <noreply@github.com>2024-06-14 11:02:36 +0200
commit81b372fecd749d350fbd86be1f65146b2df97b70 (patch)
tree9c1cfed1c2b1cf1eeaa91f725358646c56159e2d /runtime/lua/vim
parent29e05cfb7ecd2abeac397c2ef2466166d18e1f41 (diff)
downloadrneovim-81b372fecd749d350fbd86be1f65146b2df97b70.tar.gz
rneovim-81b372fecd749d350fbd86be1f65146b2df97b70.tar.bz2
rneovim-81b372fecd749d350fbd86be1f65146b2df97b70.zip
fix(lsp): check for nil response from server (#29196)
this only changes the error message, so that it is clear that the error is with the LSP server, rather than being a crash inside nvim runtime scripts. We are already doing a lot of validation, it's just that nil was being overlooked here. This fixes issue #27395
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/lsp/rpc.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua
index 5e2b041a0a..7acb67b25e 100644
--- a/runtime/lua/vim/lsp/rpc.lua
+++ b/runtime/lua/vim/lsp/rpc.lua
@@ -407,7 +407,9 @@ function Client:handle_body(body)
end
log.debug('rpc.receive', decoded)
- if type(decoded.method) == 'string' and decoded.id then
+ if type(decoded) ~= 'table' then
+ self:on_error(M.client_errors.INVALID_SERVER_MESSAGE, decoded)
+ elseif type(decoded.method) == 'string' and decoded.id then
local err --- @type lsp.ResponseError|nil
-- Schedule here so that the users functions don't trigger an error and
-- we can still use the result.