From 838631e29ef3051d6117b3d5c340d2be9f1f29b4 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Sat, 1 Jan 2022 12:58:34 -0700 Subject: 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. --- test/functional/lua/diagnostic_spec.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/functional/lua') 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") -- cgit