aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/diagnostic_spec.lua
diff options
context:
space:
mode:
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2023-09-06 20:54:18 +0300
committerGitHub <noreply@github.com>2023-09-06 12:54:18 -0500
commitd27214331815324ea5762b5aa22996b9019085c6 (patch)
treec8e6e9c287ff88e89013161073a72f34fa00a7b7 /test/functional/lua/diagnostic_spec.lua
parent2ef7b6a433c61837bcef0fca297a665551835423 (diff)
downloadrneovim-d27214331815324ea5762b5aa22996b9019085c6.tar.gz
rneovim-d27214331815324ea5762b5aa22996b9019085c6.tar.bz2
rneovim-d27214331815324ea5762b5aa22996b9019085c6.zip
fix(diagnostic): always return copies of diagnostic items (#25010)
Diffstat (limited to 'test/functional/lua/diagnostic_spec.lua')
-rw-r--r--test/functional/lua/diagnostic_spec.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index 27ba70f057..8deb2e0726 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -181,6 +181,18 @@ describe('vim.diagnostic', function()
eq(0, #diagnostics)
end)
+ it('always returns a copy of diagnostic tables', function()
+ local result = exec_lua [[
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
+ make_error('Diagnostic #1', 1, 1, 1, 1),
+ })
+ local diag = vim.diagnostic.get()
+ diag[1].col = 10000
+ return vim.diagnostic.get()[1].col == 10000
+ ]]
+ eq(result, false)
+ end)
+
it('resolves buffer number 0 to the current buffer', function()
eq(2, exec_lua [[
vim.api.nvim_set_current_buf(diagnostic_bufnr)