mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
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:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
c5262c4ca8
commit
d31953d532
@@ -2620,7 +2620,9 @@ function M.toqflist(diagnostics)
|
|||||||
end_lnum = v.end_lnum and (v.end_lnum + 1) or nil,
|
end_lnum = v.end_lnum and (v.end_lnum + 1) or nil,
|
||||||
end_col = v.end_col and (v.end_col + 1) or nil,
|
end_col = v.end_col and (v.end_col + 1) or nil,
|
||||||
text = v.message,
|
text = v.message,
|
||||||
|
nr = tonumber(v.code),
|
||||||
type = errlist_type_map[v.severity] or 'E',
|
type = errlist_type_map[v.severity] or 'E',
|
||||||
|
valid = 1,
|
||||||
}
|
}
|
||||||
table.insert(list, item)
|
table.insert(list, item)
|
||||||
end
|
end
|
||||||
@@ -2652,7 +2654,8 @@ function M.fromqflist(list)
|
|||||||
local col = math.max(0, item.col - 1)
|
local col = math.max(0, item.col - 1)
|
||||||
local end_lnum = item.end_lnum > 0 and (item.end_lnum - 1) or lnum
|
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 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] = {
|
diagnostics[#diagnostics + 1] = {
|
||||||
bufnr = item.bufnr,
|
bufnr = item.bufnr,
|
||||||
lnum = lnum,
|
lnum = lnum,
|
||||||
@@ -2661,6 +2664,7 @@ function M.fromqflist(list)
|
|||||||
end_col = end_col,
|
end_col = end_col,
|
||||||
severity = severity,
|
severity = severity,
|
||||||
message = item.text,
|
message = item.text,
|
||||||
|
code = code,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user