Skip to content

Commit

Permalink
fix(lsp): check for nil on faulty lsp results
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 31, 2024
1 parent 8adafc1 commit d7f69ff
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 0 additions & 3 deletions .nvim.lsp.json

This file was deleted.

4 changes: 2 additions & 2 deletions lua/trouble/sources/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ function M.call_hierarchy(cb, incoming)
---@cast chis lsp.CallHierarchyItem[]
for _, chi in ipairs(chis) do
M.request(("callHierarchy/%sCalls"):format(incoming and "incoming" or "outgoing"), { item = chi }, function(res)
local calls = res[client] --[[@as (lsp.CallHierarchyIncomingCall|lsp.CallHierarchyOutgoingCall)[] ]]
local calls = res[client] or {} --[[@as (lsp.CallHierarchyIncomingCall|lsp.CallHierarchyOutgoingCall)[] ]]
local todo = {} ---@type lsp.ResultItem[]

for _, call in ipairs(calls) do
if incoming then
for _, r in ipairs(call.fromRanges) do
for _, r in ipairs(call.fromRanges or {}) do
local t = vim.deepcopy(chi) --[[@as lsp.ResultItem]]
t.location = { range = r or call.from.selectionRange or call.from.range, uri = call.from.uri }
todo[#todo + 1] = t
Expand Down

0 comments on commit d7f69ff

Please sign in to comment.