mirror of
https://github.com/neovim/neovim.git
synced 2026-04-19 14:00:49 +00:00
fix(diagnostic): check for extmark in get_logical_pos #37127
Problem: The function get_logical_pos did not account for the possibility that a diagnostic might not have an associated extmark, leading to potential errors or incorrect behavior. Solution: Add a check for diagnostic._extmark_id and return the logical positions directly if it does not exist.
This commit is contained in:
@@ -608,6 +608,21 @@ describe('vim.diagnostic', function()
|
||||
vim.diagnostic.hide(_G.diagnostic_ns)
|
||||
end)
|
||||
end)
|
||||
|
||||
it('handles diagnostics without extmark_id', function()
|
||||
exec_lua(function()
|
||||
vim.diagnostic.config({ virtual_text = true })
|
||||
|
||||
vim.diagnostic.set(_G.diagnostic_ns, _G.diagnostic_bufnr, {
|
||||
_G.make_error('Error message', 0, 0, 0, 5),
|
||||
})
|
||||
|
||||
local diags = vim.diagnostic.get(_G.diagnostic_bufnr, { namespace = _G.diagnostic_ns })
|
||||
diags[1]._extmark_id = nil
|
||||
|
||||
vim.diagnostic.show(_G.diagnostic_ns, _G.diagnostic_bufnr, diags)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('enable() and disable()', function()
|
||||
|
||||
Reference in New Issue
Block a user