Skip to content

Commit

Permalink
fix(diagnostic): avoid arithmetic error when adding 1 to nil (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Apr 28, 2024
1 parent 2673ac0 commit 44536f5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lua/neotest/consumers/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,16 @@ local function init(client)
local mark_code = api.nvim_buf_get_lines(bufnr, mark[1], mark[1] + 1, false)[1]

if mark_code == self.error_code_lines[pos_id][error_i] then
local col = mark_code:find("%S")
if col then
col = col - 1
else
col = 0
end

diagnostics[#diagnostics + 1] = {
lnum = mark[1],
col = mark_code:find("%S") - 1,
col = col,
message = error.message,
source = "neotest",
severity = config.diagnostic.severity,
Expand Down

0 comments on commit 44536f5

Please sign in to comment.