mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
fix(diagnostic): check for sign namespace instead of sign group
This commit is contained in:
parent
8122470f83
commit
29d5ff6ac4
@ -897,7 +897,7 @@ M.handlers.signs = {
|
|||||||
end,
|
end,
|
||||||
hide = function(namespace, bufnr)
|
hide = function(namespace, bufnr)
|
||||||
local ns = M.get_namespace(namespace)
|
local ns = M.get_namespace(namespace)
|
||||||
if ns.user_data.sign_group and api.nvim_buf_is_valid(bufnr) then
|
if ns.user_data.sign_ns and api.nvim_buf_is_valid(bufnr) then
|
||||||
api.nvim_buf_clear_namespace(bufnr, ns.user_data.sign_ns, 0, -1)
|
api.nvim_buf_clear_namespace(bufnr, ns.user_data.sign_ns, 0, -1)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -1495,32 +1495,47 @@ end)
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('sets signs', function()
|
it('sets and clears signs #26193 #26555', function()
|
||||||
local result = exec_lua [[
|
do
|
||||||
vim.diagnostic.config({
|
local result = exec_lua [[
|
||||||
signs = true,
|
vim.diagnostic.config({
|
||||||
})
|
signs = true,
|
||||||
|
})
|
||||||
|
|
||||||
local diagnostics = {
|
local diagnostics = {
|
||||||
make_error('Error', 1, 1, 1, 2),
|
make_error('Error', 1, 1, 1, 2),
|
||||||
make_warning('Warning', 3, 3, 3, 3),
|
make_warning('Warning', 3, 3, 3, 3),
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
|
||||||
|
|
||||||
local ns = vim.diagnostic.get_namespace(diagnostic_ns)
|
local ns = vim.diagnostic.get_namespace(diagnostic_ns)
|
||||||
local sign_ns = ns.user_data.sign_ns
|
local sign_ns = ns.user_data.sign_ns
|
||||||
|
|
||||||
local signs = vim.api.nvim_buf_get_extmarks(diagnostic_bufnr, sign_ns, 0, -1, {type ='sign', details = true})
|
local signs = vim.api.nvim_buf_get_extmarks(diagnostic_bufnr, sign_ns, 0, -1, {type ='sign', details = true})
|
||||||
local result = {}
|
local result = {}
|
||||||
for _, s in ipairs(signs) do
|
for _, s in ipairs(signs) do
|
||||||
result[#result + 1] = { lnum = s[2] + 1, name = s[4].sign_hl_group }
|
result[#result + 1] = { lnum = s[2] + 1, name = s[4].sign_hl_group }
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
]]
|
]]
|
||||||
|
|
||||||
eq({2, 'DiagnosticSignError'}, {result[1].lnum, result[1].name})
|
eq({2, 'DiagnosticSignError'}, {result[1].lnum, result[1].name})
|
||||||
eq({4, 'DiagnosticSignWarn'}, {result[2].lnum, result[2].name})
|
eq({4, 'DiagnosticSignWarn'}, {result[2].lnum, result[2].name})
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local result = exec_lua [[
|
||||||
|
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {})
|
||||||
|
|
||||||
|
local ns = vim.diagnostic.get_namespace(diagnostic_ns)
|
||||||
|
local sign_ns = ns.user_data.sign_ns
|
||||||
|
|
||||||
|
return vim.api.nvim_buf_get_extmarks(diagnostic_bufnr, sign_ns, 0, -1, {type ='sign', details = true})
|
||||||
|
]]
|
||||||
|
|
||||||
|
eq({}, result)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user