aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/diagnostic_spec.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2022-01-01 12:58:34 -0700
committerGitHub <noreply@github.com>2022-01-01 12:58:34 -0700
commit838631e29ef3051d6117b3d5c340d2be9f1f29b4 (patch)
tree9b3f392e82cb89605dfc72666f08e2bf496bc976 /test/functional/lua/diagnostic_spec.lua
parent55c4393e9f80ac3e7233da889efce4f760e41664 (diff)
downloadrneovim-838631e29ef3051d6117b3d5c340d2be9f1f29b4.tar.gz
rneovim-838631e29ef3051d6117b3d5c340d2be9f1f29b4.tar.bz2
rneovim-838631e29ef3051d6117b3d5c340d2be9f1f29b4.zip
fix(diagnostic): improve validation for list arguments (#16855)
Function arguments that expect a list should explicitly use tbl_islist rather than just checking for a table. This helps catch some simple errors where a single table item is passed as an argument, which passes validation (since it's a table), but causes other errors later on.
Diffstat (limited to 'test/functional/lua/diagnostic_spec.lua')
-rw-r--r--test/functional/lua/diagnostic_spec.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index a88da63e90..7d260f2e29 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -1119,6 +1119,11 @@ describe('vim.diagnostic', function()
end)
describe('set()', function()
+ it('validates its arguments', function()
+ matches("expected a list of diagnostics",
+ pcall_err(exec_lua, [[vim.diagnostic.set(1, 0, {lnum = 1, col = 2})]]))
+ end)
+
it('can perform updates after insert_leave', function()
exec_lua [[vim.api.nvim_set_current_buf(diagnostic_bufnr)]]
nvim("input", "o")