From cfaf68420e9f493ee7783ba243e262be7c7f4d08 Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Thu, 12 Sep 2024 01:07:47 +0000 Subject: [PATCH] fix(lsp): handle empty call hierarchy items (#3288) - Added a check for empty call hierarchy items using vim.tbl_isempty. - Fixed the return value to correctly return the chosen item from the list. --- lua/telescope/builtin/__lsp.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/telescope/builtin/__lsp.lua b/lua/telescope/builtin/__lsp.lua index 27e65f9a79..662a6af9b9 100644 --- a/lua/telescope/builtin/__lsp.lua +++ b/lua/telescope/builtin/__lsp.lua @@ -50,7 +50,7 @@ local function call_hierarchy(opts, method, title, direction, item) end local function pick_call_hierarchy_item(call_hierarchy_items) - if not call_hierarchy_items then + if not call_hierarchy_items or vim.tbl_isempty(call_hierarchy_items) then return end if #call_hierarchy_items == 1 then @@ -65,7 +65,7 @@ local function pick_call_hierarchy_item(call_hierarchy_items) if choice < 1 or choice > #items then return end - return choice + return call_hierarchy_items[choice] end local function calls(opts, direction)