diff options
author | Famiu Haque <famiuhaque@protonmail.com> | 2022-05-05 01:49:29 +0600 |
---|---|---|
committer | Famiu Haque <famiuhaque@protonmail.com> | 2022-05-05 20:35:14 +0600 |
commit | 7aedcd8febaf74403851f8482529302e3ab30922 (patch) | |
tree | 68754c8f27c0a26919d2a56412dea60732551b57 /test/functional/api/vim_spec.lua | |
parent | e6c71574a07662c44b83c6cb07bf9b61bc06e136 (diff) | |
download | rneovim-7aedcd8febaf74403851f8482529302e3ab30922.tar.gz rneovim-7aedcd8febaf74403851f8482529302e3ab30922.tar.bz2 rneovim-7aedcd8febaf74403851f8482529302e3ab30922.zip |
refactor(api): make `range` in `nvim_parse_cmd` an array
Changes the `range` value in `nvim_parse_cmd` into an array to describe
range information more concisely. Also makes `range` and `count` be
mutually exclusive by making count `-1` when command takes a range
instead of a count. Additionally corrects the behavior of `count` for
built-in commands by making the default count `0`.
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r-- | test/functional/api/vim_spec.lua | 76 |
1 files changed, 9 insertions, 67 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 7e54ae0248..610036f484 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3104,9 +3104,7 @@ describe('API', function() cmd = 'echo', args = { 'foo' }, bang = false, - line1 = -1, - line2 = -1, - range = 0, + range = {}, count = -1, reg = '', addr = 'none', @@ -3142,9 +3140,7 @@ describe('API', function() cmd = 'substitute', args = { '/math.random/math.max/' }, bang = false, - line1 = 4, - line2 = 6, - range = 2, + range = { 4, 6 }, count = -1, reg = '', addr = 'line', @@ -3180,9 +3176,7 @@ describe('API', function() cmd = 'buffer', args = {}, bang = false, - line1 = 1, - line2 = 1, - range = 1, + range = {}, count = 1, reg = '', addr = 'buf', @@ -3218,9 +3212,7 @@ describe('API', function() cmd = 'put', args = {}, bang = false, - line1 = 1, - line2 = 1, - range = 0, + range = {}, count = -1, reg = '+', addr = 'line', @@ -3256,9 +3248,7 @@ describe('API', function() cmd = 'write', args = {}, bang = true, - line1 = 1, - line2 = 1, - range = 0, + range = {}, count = -1, reg = '', addr = 'line', @@ -3294,9 +3284,7 @@ describe('API', function() cmd = 'split', args = { 'foo.txt' }, bang = false, - line1 = 1, - line2 = 1, - range = 0, + range = {}, count = -1, reg = '', addr = '?', @@ -3333,9 +3321,7 @@ describe('API', function() cmd = 'MyCommand', args = { 'test', 'it' }, bang = true, - line1 = 4, - line2 = 6, - range = 2, + range = { 4, 6 }, count = -1, reg = '', addr = 'line', @@ -3371,9 +3357,7 @@ describe('API', function() cmd = 'argadd', args = { 'a.txt' }, bang = false, - line1 = 0, - line2 = 0, - range = 0, + range = {}, count = -1, reg = '', addr = 'arg', @@ -3410,9 +3394,7 @@ describe('API', function() cmd = 'MyCommand', args = { 'test it' }, bang = false, - line1 = -1, - line2 = -1, - range = 0, + range = {}, count = -1, reg = '', addr = 'none', @@ -3443,46 +3425,6 @@ describe('API', function() } }, meths.parse_cmd('MyCommand test it', {})) end) - it('sets correct default range', function() - command('command -range=% -addr=buffers MyCommand echo foo') - command('new') - eq({ - cmd = 'MyCommand', - args = {}, - bang = false, - line1 = 1, - line2 = 2, - range = 0, - count = -1, - reg = '', - addr = 'buf', - magic = { - file = false, - bar = false - }, - 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('MyCommand', {})) - end) it('errors for invalid command', function() eq('Error while parsing command line', pcall_err(meths.parse_cmd, 'Fubar', {})) command('command! Fubar echo foo') |