aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-06-28 04:51:55 -0700
committerGitHub <noreply@github.com>2023-06-28 04:51:55 -0700
commite0453d7f5743ad2f515deea76e363d11a7e1fa96 (patch)
tree72953f5e23a89cfb6f5a96831ab2fe5dc0273534 /test/functional/api/vim_spec.lua
parent42f9573e5da64d6eb8e0dd9ccfefadb68773202c (diff)
downloadrneovim-e0453d7f5743ad2f515deea76e363d11a7e1fa96.tar.gz
rneovim-e0453d7f5743ad2f515deea76e363d11a7e1fa96.tar.bz2
rneovim-e0453d7f5743ad2f515deea76e363d11a7e1fa96.zip
fix(api): nvim_cmd{cmd="win_getid"} parsed as :winsize #24181
Problem: `:lua vim.cmd.win_getid(30,10)` is interpreted as `:win[size] 30 10`. User intention was to call `vim.fn.win_getid(30,10)`. Solution: Check that the `cmd` actually matches the resolved command.
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index d56f780ca6..1ac732b128 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -335,8 +335,7 @@ describe('API', function()
nvim('command', 'edit '..fname)
nvim('command', 'normal itesting\napi')
nvim('command', 'w')
- local f = io.open(fname)
- ok(f ~= nil)
+ local f = assert(io.open(fname))
if is_os('win') then
eq('testing\r\napi\r\n', f:read('*a'))
else
@@ -3950,7 +3949,7 @@ describe('API', function()
}
}, meths.parse_cmd('MyCommand test it', {}))
end)
- it('errors for invalid command', function()
+ it('validates command', function()
eq('Error while parsing command line', pcall_err(meths.parse_cmd, '', {}))
eq('Error while parsing command line', pcall_err(meths.parse_cmd, '" foo', {}))
eq('Error while parsing command line: E492: Not an editor command: Fubar',
@@ -4097,6 +4096,11 @@ describe('API', function()
eq("Invalid 'reg': expected single character, got xx",
pcall_err(meths.cmd, { cmd = "put", args = {}, reg = 'xx' }, {}))
+ -- #20681
+ eq('Invalid command: "win_getid"', pcall_err(meths.cmd, { cmd = 'win_getid'}, {}))
+ eq('Invalid command: "echo "hi""', pcall_err(meths.cmd, { cmd = 'echo "hi"'}, {}))
+ eq('Invalid command: "win_getid"', pcall_err(exec_lua, [[return vim.cmd.win_getid{}]]))
+
-- Lua call allows empty {} for dict item.
eq('', exec_lua([[return vim.cmd{ cmd = "set", args = {}, magic = {} }]]))
eq('', exec_lua([[return vim.cmd{ cmd = "set", args = {}, mods = {} }]]))