commit 583308f5991c4c55d3f04e456254d95433033c72
parent 4ef217e272c463896b73ba726b0a498c497413a0
Author: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
Date: Wed, 25 Feb 2026 19:26:56 +0100
fix(diagnostic): handle stale diagnostic extmark ids #38060
Problem:
If a server is slow with catching up, there can be stale diagnostics
for deleted lines. Then if a user uses `jump` it can error like:
E5108: Lua: ...runtime/lua/vim/diagnostic.lua:670: attempt to index a nil value
stack traceback:
...runtime/lua/vim/diagnostic.lua:670: in function 'get_logical_pos'
...runtime/lua/vim/diagnostic.lua:687: in function 'diagnostic_lines'
...runtime/lua/vim/diagnostic.lua:1122: in function 'next_diagnostic'
...runtime/lua/vim/diagnostic.lua:1665: in function 'jump'
Solution:
Fallback to diagnostic location. That's better than the failure.
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
@@ -666,7 +666,9 @@ local function get_logical_pos(diagnostic)
diagnostic._extmark_id,
{ details = true }
)
-
+ if next(extmark) == nil then
+ return diagnostic.lnum, diagnostic.col, diagnostic.end_lnum, diagnostic.end_col, true
+ end
return extmark[1], extmark[2], extmark[3].end_row, extmark[3].end_col, not extmark[3].invalid
end