Skip to content

Commit

Permalink
fix(qf): properly deal with invalid qf entries. Fixes #87. Fixes #188.
Browse files Browse the repository at this point in the history
…Fixes #336
  • Loading branch information
folke committed Oct 7, 2023
1 parent 3f85d8e commit 46b60e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
32 changes: 20 additions & 12 deletions lua/trouble/providers/qf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,27 @@ function M.get_list(winid)
local row = (item.lnum == 0 and 1 or item.lnum) - 1
local col = (item.col == 0 and 1 or item.col) - 1

local pitem = {
row = row,
col = col,
message = item.text,
severity = severities[item.type] or 0,
range = {
start = { line = row, character = col },
["end"] = { line = row, character = -1 },
},
}

table.insert(ret, util.process_item(pitem, item.bufnr))
if item.valid == 1 then
ret[#ret + 1] = {
row = row,
col = col,
message = item.text,
severity = severities[item.type] or 0,
bufnr = item.bufnr,
range = {
start = { line = row, character = col },
["end"] = { line = row, character = -1 },
},
}
elseif #ret > 0 then
ret[#ret].message = ret[#ret].message .. "\n" .. item.text
end
end

for i, item in ipairs(ret) do
ret[i] = util.process_item(item)
end

return ret
end

Expand Down
3 changes: 3 additions & 0 deletions lua/trouble/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ function View:_preview()
if not vim.api.nvim_win_is_valid(self.parent) then
return
end
if not vim.api.nvim_win_is_valid(self.win) then
return
end

local item = self:current_item()
if not item then
Expand Down

0 comments on commit 46b60e9

Please sign in to comment.