Skip to content

Commit

Permalink
fix(lsp): use document uri of document symbols don't have an uri set. F…
Browse files Browse the repository at this point in the history
…ixes #480
  • Loading branch information
folke committed Jun 5, 2024
1 parent 9151797 commit 358f0ee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/trouble/sources/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ function M.get.document_symbols(cb)
M.request("textDocument/documentSymbol", params):next(
---@param results trouble.lsp.Response<lsp.SymbolInformation[]|lsp.DocumentSymbol[]>[]
function(results)
if vim.tbl_isempty(results) then
return cb({})
end
if not vim.api.nvim_buf_is_valid(buf) then
return
end
Expand Down Expand Up @@ -354,8 +357,9 @@ function M.results_to_items(client, results, default_uri)
---@param result lsp.ResultItem
local function process(result)
local uri = result.location and result.location.uri or result.uri or default_uri
assert(uri, "missing uri in result:\n" .. vim.inspect(result))
local loc = result.location or { range = result.selectionRange or result.range, uri = uri }
loc.uri = loc.uri or uri
assert(loc.uri, "missing uri in result:\n" .. vim.inspect(result))
-- the range enclosing this symbol. Useful to get the symbol of the current cursor position
---@type lsp.Location?
local range = result.range and { range = result.range, uri = uri } or nil
Expand Down

0 comments on commit 358f0ee

Please sign in to comment.