aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/diagnostic.lua
diff options
context:
space:
mode:
authorRaphael <glephunter@gmail.com>2024-04-28 05:05:41 +0800
committerGitHub <noreply@github.com>2024-04-27 16:05:41 -0500
commit96f59e1b9902f7622eaaea02eea0329a88b98202 (patch)
tree0e6934bef39349b4bb10bfbb775db9a4c80c75c5 /runtime/lua/vim/diagnostic.lua
parent158e3297255cc82b2830e08d2067948cc4a8521f (diff)
downloadrneovim-96f59e1b9902f7622eaaea02eea0329a88b98202.tar.gz
rneovim-96f59e1b9902f7622eaaea02eea0329a88b98202.tar.bz2
rneovim-96f59e1b9902f7622eaaea02eea0329a88b98202.zip
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.
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r--runtime/lua/vim/diagnostic.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 1ae370e9b2..9f1e6448e6 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -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)