Skip to content

Commit 426b5ed

Browse files
Marc Jakobimrcjkb
authored andcommitted
fix(test): correct diagnostic position
1 parent 0ad4cbd commit 426b5ed

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lua/rustaceanvim/test.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ function M.parse_cargo_test_diagnostics(output, bufnr)
3131
for failure_content, test_id, lnum, col in
3232
output:gmatch("(thread '([^']+)' panicked at [^:]+:(%d+):(%d+):%s-\n.-\n)\n")
3333
do
34+
local diagnostic_lnum = tonumber(lnum) - 1
35+
local diagnostic_col = tonumber(col) or 0
3436
table.insert(diagnostics, {
3537
bufnr = bufnr,
3638
test_id = test_id,
37-
lnum = tonumber(lnum),
38-
end_lnum = tonumber(lnum),
39-
col = tonumber(col),
40-
end_col = tonumber(col),
39+
lnum = diagnostic_lnum,
40+
end_lnum = diagnostic_lnum,
41+
col = diagnostic_col,
42+
end_col = diagnostic_col,
4143
message = remove_ansi_codes(unescape_html(failure_content)),
4244
source = 'rustaceanvim',
4345
severity = vim.diagnostic.severity.ERROR,

spec/test_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2323
local expected = {
2424
{
2525
bufnr = 0,
26-
lnum = 86,
27-
end_lnum = 86,
26+
lnum = 85,
27+
end_lnum = 85,
2828
col = 64,
2929
end_col = 64,
3030
message = [[

0 commit comments

Comments
 (0)