aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/diagnostic_spec.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 /test/functional/lua/diagnostic_spec.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 'test/functional/lua/diagnostic_spec.lua')
-rw-r--r--test/functional/lua/diagnostic_spec.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index 534d78fd09..2e6f7fbf36 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -1101,6 +1101,29 @@ describe('vim.diagnostic', function()
]]
)
end)
+
+ it('works on blank line #28397', function()
+ eq(
+ { 0, 2 },
+ exec_lua [[
+ local test_bufnr = vim.api.nvim_create_buf(true, false)
+ vim.api.nvim_buf_set_lines(test_bufnr, 0, -1, false, {
+ 'first line',
+ '',
+ '',
+ 'end line',
+ })
+ vim.diagnostic.set(diagnostic_ns, test_bufnr, {
+ make_info('Diagnostic #1', 0, 2, 0, 2),
+ make_info('Diagnostic #2', 2, 0, 2, 0),
+ make_info('Diagnostic #3', 2, 0, 2, 0),
+ })
+ vim.api.nvim_win_set_buf(0, test_bufnr)
+ vim.api.nvim_win_set_cursor(0, {3, 0})
+ return vim.diagnostic.get_prev_pos { namespace = diagnostic_ns}
+ ]]
+ )
+ end)
end)
describe('get()', function()