diff --git a/lua/neotest/consumers/diagnostic.lua b/lua/neotest/consumers/diagnostic.lua index 30191fa..928c7af 100644 --- a/lua/neotest/consumers/diagnostic.lua +++ b/lua/neotest/consumers/diagnostic.lua @@ -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(