commit e4a100a1e1c0fd7dfe4162b5b1c1e228ec9729e7
parent 1f7432a27274093169dfe0f333041c269e2f5159
Author: Mike <4576770+mike325@users.noreply.github.com>
Date: Fri, 25 Jul 2025 15:14:00 +0200
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
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
@@ -2692,7 +2692,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
@@ -2724,7 +2726,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,
@@ -2733,6 +2736,7 @@ function M.fromqflist(list)
end_col = end_col,
severity = severity,
message = item.text,
+ code = code,
}
end
end