aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/lua')
-rw-r--r--test/functional/lua/diagnostic_spec.lua19
1 files changed, 13 insertions, 6 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index b58fad1cab..7f929db8bf 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -1939,24 +1939,31 @@ describe('vim.diagnostic', function()
end)
it('triggers the autocommand when diagnostics are set', function()
- eq(1, exec_lua [[
+ eq(true, exec_lua [[
+ -- Set a different buffer as current to test that <abuf> is being set properly in
+ -- DiagnosticChanged callbacks
+ local tmp = vim.api.nvim_create_buf(false, true)
+ vim.api.nvim_set_current_buf(tmp)
+
vim.g.diagnostic_autocmd_triggered = 0
- vim.cmd('autocmd DiagnosticChanged * let g:diagnostic_autocmd_triggered = 1')
+ vim.cmd('autocmd DiagnosticChanged * let g:diagnostic_autocmd_triggered = +expand("<abuf>")')
vim.api.nvim_buf_set_name(diagnostic_bufnr, "test | test")
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
make_error('Diagnostic', 0, 0, 0, 0)
})
- return vim.g.diagnostic_autocmd_triggered
+ return vim.g.diagnostic_autocmd_triggered == diagnostic_bufnr
]])
end)
it('triggers the autocommand when diagnostics are cleared', function()
- eq(1, exec_lua [[
+ eq(true, exec_lua [[
+ local tmp = vim.api.nvim_create_buf(false, true)
+ vim.api.nvim_set_current_buf(tmp)
vim.g.diagnostic_autocmd_triggered = 0
- vim.cmd('autocmd DiagnosticChanged * let g:diagnostic_autocmd_triggered = 1')
+ vim.cmd('autocmd DiagnosticChanged * let g:diagnostic_autocmd_triggered = +expand("<abuf>")')
vim.api.nvim_buf_set_name(diagnostic_bufnr, "test | test")
vim.diagnostic.reset(diagnostic_ns, diagnostic_bufnr)
- return vim.g.diagnostic_autocmd_triggered
+ return vim.g.diagnostic_autocmd_triggered == diagnostic_bufnr
]])
end)
end)