diff options
author | James Trew <66286082+jamestrew@users.noreply.github.com> | 2024-09-13 11:59:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-13 04:59:49 -0700 |
commit | 8654a9700690a715e35baa600bb982f4ea608ead (patch) | |
tree | fa9b8c53d424498e49035ca1650680cd727e58d3 /runtime/lua/vim/lsp/buf.lua | |
parent | 057314345a7cfc8e52bbe13a595759d6ca52ac20 (diff) | |
download | rneovim-8654a9700690a715e35baa600bb982f4ea608ead.tar.gz rneovim-8654a9700690a715e35baa600bb982f4ea608ead.tar.bz2 rneovim-8654a9700690a715e35baa600bb982f4ea608ead.zip |
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 (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index e51727ef13..a43ad8a690 100644 --- 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 |