fix: read difinitions (#1672)
This commit is contained in:
@@ -79,18 +79,19 @@ function M.read_definitions(bufnr, symbol_name, show_line_numbers, on_complete)
|
|||||||
on_complete(nil, "No results")
|
on_complete(nil, "No results")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
---@type avante.lsp.Definition[]
|
||||||
|
local res = {}
|
||||||
for _, result in ipairs(results) do
|
for _, result in ipairs(results) do
|
||||||
if result.error then
|
if result.error then
|
||||||
on_complete(nil, result.error.message)
|
on_complete(nil, result.error.message)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if not result.result then goto continue end
|
||||||
local definitions = vim.tbl_filter(function(d) return d.name == symbol_name end, result.result)
|
local definitions = vim.tbl_filter(function(d) return d.name == symbol_name end, result.result)
|
||||||
if #definitions == 0 then
|
if #definitions == 0 then
|
||||||
on_complete(nil, "No definition found")
|
on_complete(nil, "No definition found")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
---@type avante.lsp.Definition[]
|
|
||||||
local res = {}
|
|
||||||
for _, definition in ipairs(definitions) do
|
for _, definition in ipairs(definitions) do
|
||||||
local lines = get_full_definition(definition.location)
|
local lines = get_full_definition(definition.location)
|
||||||
if show_line_numbers then
|
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
|
local uri = definition.location.uri
|
||||||
table.insert(res, { content = table.concat(lines, "\n"), uri = uri })
|
table.insert(res, { content = table.concat(lines, "\n"), uri = uri })
|
||||||
end
|
end
|
||||||
on_complete(res, nil)
|
::continue::
|
||||||
end
|
end
|
||||||
|
on_complete(res, nil)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user