mirror of
https://github.com/neovim/neovim.git
synced 2026-03-30 20:32:08 +00:00
fix(diagnostics): assert adjusted diagnostic position #37210
Problem: During diagnostic position adjustment we may go out of bounds when trying to get line's length. But it's not clear what kind of input triggers that. Solution: Assert and print relevant input values.
This commit is contained in:
committed by
GitHub
parent
e6d955cb2c
commit
f7b573f80a
@@ -1390,7 +1390,25 @@ function M.set(namespace, bufnr, diagnostics, opts)
|
||||
-- avoid ending an extmark before start of the line
|
||||
if end_col == 0 then
|
||||
end_row = end_row - 1
|
||||
end_col = #lines[end_row + 1]
|
||||
|
||||
local end_line = lines[end_row + 1]
|
||||
|
||||
if not end_line then
|
||||
error(
|
||||
'Failed to adjust diagnostic position to the end of a previous line. #lines in a buffer: '
|
||||
.. #lines
|
||||
.. ', lnum: '
|
||||
.. diagnostic.lnum
|
||||
.. ', col: '
|
||||
.. diagnostic.col
|
||||
.. ', end_lnum: '
|
||||
.. diagnostic.end_lnum
|
||||
.. ', end_col: '
|
||||
.. diagnostic.end_col
|
||||
)
|
||||
end
|
||||
|
||||
end_col = #end_line
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user