From d31953d532621ab77cf18009138fca1564f1b781 Mon Sep 17 00:00:00 2001 From: Mike <4576770+mike325@users.noreply.github.com> Date: Fri, 25 Jul 2025 15:14:00 +0200 Subject: [PATCH] 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 e4a100a1e1c0fd7dfe4162b5b1c1e228ec9729e7) --- runtime/lua/vim/diagnostic.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 9c6a91f833..ac4fefaa2c 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -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