neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 8654a9700690a715e35baa600bb982f4ea608ead
parent 057314345a7cfc8e52bbe13a595759d6ca52ac20
Author: James Trew <66286082+jamestrew@users.noreply.github.com>
Date:   Fri, 13 Sep 2024 11:59:49 +0000

fix(lsp): handle empty call hierarchy items #30349

Ensure that the function `pick_call_hierarchy_item` correctly handles
the case where `call_hierarchy_items` is nil or an empty table. This
prevents potential errors when the function is called with no items.
Diffstat:
Mruntime/lua/vim/lsp/buf.lua | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua @@ -447,11 +447,9 @@ function M.document_symbol(opts) request_with_opts(ms.textDocument_documentSymbol, params, opts) end ---- @param call_hierarchy_items lsp.CallHierarchyItem[]? +--- @param call_hierarchy_items lsp.CallHierarchyItem[] +--- @return lsp.CallHierarchyItem? local function pick_call_hierarchy_item(call_hierarchy_items) - if not call_hierarchy_items then - return - end if #call_hierarchy_items == 1 then return call_hierarchy_items[1] end @@ -476,7 +474,7 @@ local function call_hierarchy(method) vim.notify(err.message, vim.log.levels.WARN) return end - if not result then + if not result or vim.tbl_isempty(result) then vim.notify('No item resolved', vim.log.levels.WARN) return end