mirror of
https://github.com/neovim/neovim.git
synced 2025-11-21 09:36:29 +00:00
fix(diagnostic): invalid col number compare in next_diagnostic (#28397)
Problem: when line is blank link then there will got an invalid column number in math.min compare. Solution: make sure the min column number is 0 not an illegal number.
This commit is contained in:
@@ -867,14 +867,14 @@ local function next_diagnostic(position, search_forward, bufnr, opts, namespace)
|
||||
return a.col < b.col
|
||||
end
|
||||
is_next = function(d)
|
||||
return math.min(d.col, line_length - 1) > position[2]
|
||||
return math.min(d.col, math.max(line_length - 1, 0)) > position[2]
|
||||
end
|
||||
else
|
||||
sort_diagnostics = function(a, b)
|
||||
return a.col > b.col
|
||||
end
|
||||
is_next = function(d)
|
||||
return math.min(d.col, line_length - 1) < position[2]
|
||||
return math.min(d.col, math.max(line_length - 1, 0)) < position[2]
|
||||
end
|
||||
end
|
||||
table.sort(line_diagnostics[lnum], sort_diagnostics)
|
||||
|
||||
Reference in New Issue
Block a user