feat(nvim_cmd): allow using first argument as count

Allows `nvim_cmd` to use the first argument as count for applicable
commands. Also adds support for non-String arguments to `nvim_cmd`.
This commit is contained in:
Famiu Haque
2022-09-28 17:43:18 +06:00
parent d9f5940997
commit e46eef75ac
4 changed files with 117 additions and 30 deletions

View File

@@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local lfs = require('lfs')
local luv = require('luv')
local fmt = string.format
local assert_alive = helpers.assert_alive
@@ -3962,5 +3963,23 @@ describe('API', function()
15 |
]]}
end)
it('works with non-String args', function()
eq('2', meths.cmd({cmd = 'echo', args = {2}}, {output = true}))
eq('1', meths.cmd({cmd = 'echo', args = {true}}, {output = true}))
end)
describe('first argument as count', function()
before_each(clear)
it('works', function()
command('vsplit | enew')
meths.cmd({cmd = 'bdelete', args = {meths.get_current_buf()}}, {})
eq(1, meths.get_current_buf().id)
end)
it('works with :sleep using milliseconds', function()
local start = luv.now()
meths.cmd({cmd = 'sleep', args = {'100m'}}, {})
ok(luv.now() - start <= 300)
end)
end)
end)
end)