Skip to content

Commit 558f7c9

Browse files
Marc Jakobimrcjkb
authored andcommitted
fix(neotest): positions lost when rust-analyzer returns duplicate namespaces
1 parent 1ebe374 commit 558f7c9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lua/rustaceanvim/neotest/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,17 @@ NeotestAdapter.discover_positions = function(file_path)
130130

131131
---@type { [string]: neotest.Position }
132132
local tests_by_name = {}
133-
---@type rustaceanvim.neotest.Position[]
133+
---@type table<string, rustaceanvim.neotest.Position>
134134
local namespaces = {}
135135
for _, pos in pairs(positions) do
136136
if pos.type == 'test' then
137137
tests_by_name[pos.name] = pos
138138
elseif pos.type == 'namespace' then
139-
table.insert(namespaces, pos)
139+
namespaces[pos.id] = pos
140140
end
141141
end
142+
namespaces = vim.tbl_values(namespaces)
143+
---@cast namespaces rustaceanvim.neotest.Position[]
142144

143145
-- sort namespaces by name from longest to shortest
144146
table.sort(namespaces, function(a, b)
@@ -398,7 +400,6 @@ function NeotestAdapter.results(spec, strategy_result)
398400
local failure_diagnostic = vim.iter(diagnostics):find(function(diag)
399401
return vim.endswith(data.id, diag.test_id)
400402
end)
401-
402403
if failure_diagnostic then
403404
results[data.id] = {
404405
status = 'failed',

0 commit comments

Comments
 (0)