fix(diagnostics): extend conversion support from/to quickfix format (#34006)

Use uppercase to check severity
Mark quickfix items as valid when converting from diagnostics
Support nr/code attribute between formats

(cherry picked from commit e4a100a1e1)
This commit is contained in:
Mike
2025-07-25 15:14:00 +02:00
committed by github-actions[bot]
parent c5262c4ca8
commit d31953d532

View File

@@ -2620,7 +2620,9 @@ function M.toqflist(diagnostics)
end_lnum = v.end_lnum and (v.end_lnum + 1) or nil,
end_col = v.end_col and (v.end_col + 1) or nil,
text = v.message,
nr = tonumber(v.code),
type = errlist_type_map[v.severity] or 'E',
valid = 1,
}
table.insert(list, item)
end
@@ -2652,7 +2654,8 @@ function M.fromqflist(list)
local col = math.max(0, item.col - 1)
local end_lnum = item.end_lnum > 0 and (item.end_lnum - 1) or lnum
local end_col = item.end_col > 0 and (item.end_col - 1) or col
local severity = item.type ~= '' and M.severity[item.type] or M.severity.ERROR
local code = item.nr > 0 and item.nr or nil
local severity = item.type ~= '' and M.severity[item.type:upper()] or M.severity.ERROR
diagnostics[#diagnostics + 1] = {
bufnr = item.bufnr,
lnum = lnum,
@@ -2661,6 +2664,7 @@ function M.fromqflist(list)
end_col = end_col,
severity = severity,
message = item.text,
code = code,
}
end
end