fix(diagnostic): virtual_lines should anchor at end_lnum, not lnum #38701

Problem: Multi-line diagnostics always render virtual lines below lnum.

Solution: Use end_lnum when placing the virt_lines extmark.
This commit is contained in:
glepnir
2026-04-07 01:22:39 +08:00
committed by GitHub
parent 1354787029
commit af707dd242
2 changed files with 10 additions and 3 deletions

View File

@@ -2395,13 +2395,13 @@ describe('vim.diagnostic', function()
eq(error_offset, result[1][1][1]:len())
end)
it('highlights diagnostics in multiple lines by default', function()
it('highlights diagnostics in multiple lines by default #38685', function()
local result = exec_lua(function()
vim.diagnostic.config({ virtual_lines = true })
vim.diagnostic.set(_G.diagnostic_ns, _G.diagnostic_bufnr, {
_G.make_error('Error here!', 0, 0, 0, 0, 'foo_server'),
_G.make_error('Another error there!', 1, 0, 1, 0, 'foo_server'),
_G.make_error('Another error there!', 1, 0, 3, 0, 'foo_server'),
})
local extmarks = _G.get_virt_lines_extmarks(_G.diagnostic_ns)
@@ -2411,6 +2411,8 @@ describe('vim.diagnostic', function()
eq(2, #result)
eq('Error here!', result[1][4].virt_lines[1][3][1])
eq('Another error there!', result[2][4].virt_lines[1][3][1])
eq(0, result[1][2])
eq(3, result[2][2])
end)
it('highlights multiple diagnostics in a single line by default', function()