feat(diagnostic): add on_jump callback option

This commit is contained in:
Maria José Solano
2025-05-04 15:18:30 -07:00
parent ba2a5a7787
commit c65817774d
4 changed files with 44 additions and 22 deletions

View File

@@ -7,6 +7,7 @@ local exec_lua = n.exec_lua
local eq = t.eq
local neq = t.neq
local matches = t.matches
local retry = t.retry
local api = n.api
local pcall_err = t.pcall_err
local fn = n.fn
@@ -1094,7 +1095,7 @@ describe('vim.diagnostic', function()
})
vim.api.nvim_win_set_buf(0, _G.diagnostic_bufnr)
vim.api.nvim_win_set_cursor(0, { 1, 1 })
vim.diagnostic.jump({ count = 1, float = false })
vim.diagnostic.jump({ count = 1 })
local next = vim.diagnostic.get_next({ namespace = _G.diagnostic_ns })
return { next.lnum, next.col }
end)
@@ -1111,7 +1112,7 @@ describe('vim.diagnostic', function()
})
vim.api.nvim_win_set_buf(0, _G.diagnostic_bufnr)
vim.api.nvim_win_set_cursor(0, { 1, 1 })
vim.diagnostic.jump({ count = 1, float = false })
vim.diagnostic.jump({ count = 1 })
local next = vim.diagnostic.get_next({ namespace = _G.diagnostic_ns })
return { next.lnum, next.col }
end)
@@ -1412,6 +1413,23 @@ describe('vim.diagnostic', function()
end)
)
end)
it('supports on_jump() handler', function()
exec_lua(function()
_G.jumped = false
vim.diagnostic.jump({
count = 1,
on_jump = function()
_G.jumped = true
end,
})
end)
retry(nil, nil, function()
eq(true, exec_lua('return _G.jumped'))
end)
end)
end)
describe('get()', function()