Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quickfix: fix handling of range-less/child tests #304

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lua/neotest/consumers/quickfix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ local init = function()
local buffer_cache = {}
for pos_id, result in pairs(results) do
if result.status == "failed" and tree:get_key(pos_id) then
local pos = assert(tree:get_key(pos_id)):data()
local node = assert(tree:get_key(pos_id))
local pos = node:data()
if pos.type == "test" then
local bufnr = buffer_cache[pos.path]
if not bufnr then
Expand All @@ -33,12 +34,13 @@ local init = function()
buffer_cache[pos.path] = bufnr
end

local range = node:closest_value_for("range")
for _, error in ipairs(result.errors or {}) do
qf_results[#qf_results + 1] = {
bufnr = bufnr > 0 and bufnr or nil,
filename = bufnr <= 0 and pos.path or nil,
lnum = (error.line or pos.range[1]) + 1,
col = pos.range[2] + 1,
lnum = (error.line or range[1]) + 1,
col = range[2] + 1,
text = error.message,
type = result.status == "failed" and "E" or "W",
}
Expand Down
Loading