aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@protonmail.com>2022-05-04 18:04:01 +0600
committerGitHub <noreply@github.com>2022-05-04 05:04:01 -0700
commit3ec93ca92cb08faed342586e86a6f21b35264376 (patch)
treedf7299c113ee1331656fc06fe49920472a61f690 /test/functional/api/vim_spec.lua
parent95b7851f620928b6a93dc0198be31959b16c53d9 (diff)
downloadrneovim-3ec93ca92cb08faed342586e86a6f21b35264376.tar.gz
rneovim-3ec93ca92cb08faed342586e86a6f21b35264376.tar.bz2
rneovim-3ec93ca92cb08faed342586e86a6f21b35264376.zip
feat(nvim_parse_cmd): add range, count, reg #18383
Adds range, count and reg to the return values of nvim_parse_cmd. Also makes line1 and line2 be -1 if the command does not take a range. Also moves nvim_parse_cmd to vimscript.c because it fits better there.
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua122
1 files changed, 111 insertions, 11 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index e138e2cc38..7e54ae0248 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -3104,8 +3104,11 @@ describe('API', function()
cmd = 'echo',
args = { 'foo' },
bang = false,
- line1 = 1,
- line2 = 1,
+ line1 = -1,
+ line2 = -1,
+ range = 0,
+ count = -1,
+ reg = '',
addr = 'none',
magic = {
file = false,
@@ -3130,7 +3133,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('echo foo', {}))
end)
@@ -3141,6 +3144,9 @@ describe('API', function()
bang = false,
line1 = 4,
line2 = 6,
+ range = 2,
+ count = -1,
+ reg = '',
addr = 'line',
magic = {
file = false,
@@ -3165,10 +3171,86 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('4,6s/math.random/math.max/', {}))
end)
+ it('works with count', function()
+ eq({
+ cmd = 'buffer',
+ args = {},
+ bang = false,
+ line1 = 1,
+ line2 = 1,
+ range = 1,
+ count = 1,
+ reg = '',
+ addr = 'buf',
+ magic = {
+ file = false,
+ bar = true
+ },
+ nargs = '*',
+ nextcmd = '',
+ mods = {
+ browse = false,
+ confirm = false,
+ emsg_silent = false,
+ hide = false,
+ keepalt = false,
+ keepjumps = false,
+ keepmarks = false,
+ keeppatterns = false,
+ lockmarks = false,
+ noautocmd = false,
+ noswapfile = false,
+ sandbox = false,
+ silent = false,
+ vertical = false,
+ split = "",
+ tab = 0,
+ verbose = -1
+ }
+ }, meths.parse_cmd('buffer 1', {}))
+ end)
+ it('works with register', function()
+ eq({
+ cmd = 'put',
+ args = {},
+ bang = false,
+ line1 = 1,
+ line2 = 1,
+ range = 0,
+ count = -1,
+ reg = '+',
+ addr = 'line',
+ magic = {
+ file = false,
+ bar = true
+ },
+ nargs = '0',
+ nextcmd = '',
+ mods = {
+ browse = false,
+ confirm = false,
+ emsg_silent = false,
+ hide = false,
+ keepalt = false,
+ keepjumps = false,
+ keepmarks = false,
+ keeppatterns = false,
+ lockmarks = false,
+ noautocmd = false,
+ noswapfile = false,
+ sandbox = false,
+ silent = false,
+ vertical = false,
+ split = "",
+ tab = 0,
+ verbose = -1
+ }
+ }, meths.parse_cmd('put +', {}))
+ end)
it('works with bang', function()
eq({
cmd = 'write',
@@ -3176,6 +3258,9 @@ describe('API', function()
bang = true,
line1 = 1,
line2 = 1,
+ range = 0,
+ count = -1,
+ reg = '',
addr = 'line',
magic = {
file = true,
@@ -3200,7 +3285,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
},
}, meths.parse_cmd('w!', {}))
end)
@@ -3211,6 +3296,9 @@ describe('API', function()
bang = false,
line1 = 1,
line2 = 1,
+ range = 0,
+ count = -1,
+ reg = '',
addr = '?',
magic = {
file = true,
@@ -3247,6 +3335,9 @@ describe('API', function()
bang = true,
line1 = 4,
line2 = 6,
+ range = 2,
+ count = -1,
+ reg = '',
addr = 'line',
magic = {
file = false,
@@ -3271,7 +3362,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('4,6MyCommand! test it', {}))
end)
@@ -3282,6 +3373,9 @@ describe('API', function()
bang = false,
line1 = 0,
line2 = 0,
+ range = 0,
+ count = -1,
+ reg = '',
addr = 'arg',
magic = {
file = true,
@@ -3306,7 +3400,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('argadd a.txt | argadd b.txt', {}))
end)
@@ -3316,8 +3410,11 @@ describe('API', function()
cmd = 'MyCommand',
args = { 'test it' },
bang = false,
- line1 = 1,
- line2 = 1,
+ line1 = -1,
+ line2 = -1,
+ range = 0,
+ count = -1,
+ reg = '',
addr = 'none',
magic = {
file = false,
@@ -3342,7 +3439,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('MyCommand test it', {}))
end)
@@ -3355,6 +3452,9 @@ describe('API', function()
bang = false,
line1 = 1,
line2 = 2,
+ range = 0,
+ count = -1,
+ reg = '',
addr = 'buf',
magic = {
file = false,
@@ -3379,7 +3479,7 @@ describe('API', function()
vertical = false,
split = "",
tab = 0,
- verbose = 0
+ verbose = -1
}
}, meths.parse_cmd('MyCommand', {}))
end)