From 18f10f520b8609c7d285f7a91b2ec25ecee52670 Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 22 Mar 2025 14:05:37 +0800 Subject: [PATCH] fix: read difinitions (#1672) --- lua/avante/utils/lsp.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/avante/utils/lsp.lua b/lua/avante/utils/lsp.lua index 7703c76..1877443 100644 --- a/lua/avante/utils/lsp.lua +++ b/lua/avante/utils/lsp.lua @@ -79,18 +79,19 @@ function M.read_definitions(bufnr, symbol_name, show_line_numbers, on_complete) on_complete(nil, "No results") return end + ---@type avante.lsp.Definition[] + local res = {} for _, result in ipairs(results) do if result.error then on_complete(nil, result.error.message) return end + if not result.result then goto continue end local definitions = vim.tbl_filter(function(d) return d.name == symbol_name end, result.result) if #definitions == 0 then on_complete(nil, "No definition found") return end - ---@type avante.lsp.Definition[] - local res = {} for _, definition in ipairs(definitions) do local lines = get_full_definition(definition.location) if show_line_numbers then @@ -104,8 +105,9 @@ function M.read_definitions(bufnr, symbol_name, show_line_numbers, on_complete) local uri = definition.location.uri table.insert(res, { content = table.concat(lines, "\n"), uri = uri }) end - on_complete(res, nil) + ::continue:: end + on_complete(res, nil) end) end