From 511f06a56e77f612f7bc8ca563ebecb7239a9914 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Thu, 5 May 2022 23:11:57 +0600 Subject: fix(api): make `nvim_parse_cmd` propagate errors Makes `nvim_parse_cmd` propagate any errors that occur while parsing to give the user a better idea of what's wrong with the command. --- test/functional/api/vim_spec.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'test/functional') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 610036f484..11c1fc6c2c 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3426,10 +3426,15 @@ describe('API', function() }, meths.parse_cmd('MyCommand test it', {})) end) it('errors for invalid command', function() - eq('Error while parsing command line', pcall_err(meths.parse_cmd, 'Fubar', {})) + 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', + pcall_err(meths.parse_cmd, 'Fubar', {})) command('command! Fubar echo foo') - eq('Error while parsing command line', pcall_err(meths.parse_cmd, 'Fubar!', {})) - eq('Error while parsing command line', pcall_err(meths.parse_cmd, '4,6Fubar', {})) + eq('Error while parsing command line: E477: No ! allowed', + pcall_err(meths.parse_cmd, 'Fubar!', {})) + eq('Error while parsing command line: E481: No range allowed', + pcall_err(meths.parse_cmd, '4,6Fubar', {})) end) end) end) -- cgit