aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/buf.lua
diff options
context:
space:
mode:
authorMarcin Szamotulski <coot@coot.me>2024-03-31 20:43:34 +0200
committerGitHub <noreply@github.com>2024-03-31 20:43:34 +0200
commit01691c5447d9222a0e84f77b7043251580de7dee (patch)
treef76c85705aee489514b870a387a0e52eee71502b /runtime/lua/vim/lsp/buf.lua
parentb25753381c6049132c5c8d02eb62df99f8a958fd (diff)
downloadrneovim-01691c5447d9222a0e84f77b7043251580de7dee.tar.gz
rneovim-01691c5447d9222a0e84f77b7043251580de7dee.tar.bz2
rneovim-01691c5447d9222a0e84f77b7043251580de7dee.zip
fix(lsp): abort callHierarchy on no result (#28102)
The `callHierarchy` function should warn the user when `textDocument/prepareCallHierarchy` didn't resolve an entity and return, rather than calling the `callHierarchy/{incoming,outgoing}Calls` method with an empty object - which is encoded as an empty list (which doesn't respect language server specification for the `callHierarchy/incomingCalls` call).
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r--runtime/lua/vim/lsp/buf.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index 50121f30b2..43f52b8116 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -461,7 +461,14 @@ local function call_hierarchy(method)
vim.notify(err.message, vim.log.levels.WARN)
return
end
+ if not result then
+ vim.notify('No item resolved', vim.log.levels.WARN)
+ return
+ end
local call_hierarchy_item = pick_call_hierarchy_item(result)
+ if not call_hierarchy_item then
+ return
+ end
local client = vim.lsp.get_client_by_id(ctx.client_id)
if client then
client.request(method, { item = call_hierarchy_item }, nil, ctx.bufnr)