Skip to content

Commit

Permalink
fix: ensure that the diagnostic parameters are complete (#179)
Browse files Browse the repository at this point in the history
* fix: ensure that the diagnostic parameters are complete

* fix: 'item.range' may be nil when exec 'workspace_diagnostics'
  • Loading branch information
0x7a7a committed Feb 19, 2023
1 parent 247f9ee commit 210969f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions lua/trouble/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,16 @@ function M.process_item(item, bufnr)
bufnr = bufnr or item.bufnr
local filename = vim.api.nvim_buf_get_name(bufnr)
local uri = vim.uri_from_bufnr(bufnr)
local range = item.range
or item.targetSelectionRange
or {
["start"] = {
character = item.col,
line = item.lnum,
},
["end"] = {
character = item.end_col,
line = item.end_lnum,
},
}
local start = range["start"]
local finish = range["end"]
local range = item.range or item.targetSelectionRange

local start = {
line = range and vim.tbl_get(range, "start", "line") or item.col,
character = range and vim.tbl_get(range, "start", "character") or item.lnum,
}
local finish = {
line = range and vim.tbl_get(range, "end", "line") or item.end_col,
character = range and vim.tbl_get(range, "end", "character") or item.end_lnum,
}

if start.character == nil or start.line == nil then
M.error("Found an item for Trouble without start range " .. vim.inspect(start))
Expand Down

0 comments on commit 210969f

Please sign in to comment.