Skip to content

Commit

Permalink
fix(diagnostic): check for nil when getting default_line (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidlatau authored Dec 27, 2024
1 parent 4cdddec commit 7664999
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lua/neotest/consumers/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ local function init(client)
local pos_id = position.id
local result = results[pos_id]
if position.type == "test" and result and result.errors and #result.errors > 0 then
local pos_by_id = positions:get_key(pos_id)
local default_line = pos_by_id and pos_by_id:closest_value_for("range")[1]
local placed = self.tracking_marks[pos_id]
or self:init_mark(
pos_id,
result.errors,
positions:get_key(pos_id):closest_value_for("range")[1]
)
or self:init_mark(pos_id, result.errors, default_line)
if placed then
for error_i, error in pairs(result.errors or {}) do
local mark = api.nvim_buf_get_extmark_by_id(
Expand Down

0 comments on commit 7664999

Please sign in to comment.