0
0
mirror of https://github.com/vim/vim.git synced 2025-10-28 09:27:14 -04:00

patch 9.0.0299: error messages for setcmdline() could be better

Problem:    Error messages for setcmdline() could be better.
Solution:   Use more specific error messages. (Yegappan Lakshmanan,
            closes #10995)
This commit is contained in:
Yegappan Lakshmanan
2022-08-28 17:25:04 +01:00
committed by Bram Moolenaar
parent 8934ec027d
commit 25f1e55562
4 changed files with 8 additions and 8 deletions

View File

@@ -4272,11 +4272,9 @@ f_setcmdline(typval_T *argvars, typval_T *rettv)
{ {
int pos = -1; int pos = -1;
if (argvars[0].v_type != VAR_STRING || argvars[0].vval.v_string == NULL) if (check_for_string_arg(argvars, 0) == FAIL
{ || check_for_opt_number_arg(argvars, 1) == FAIL)
emsg(_(e_string_required));
return; return;
}
if (argvars[1].v_type != VAR_UNKNOWN) if (argvars[1].v_type != VAR_UNKNOWN)
{ {

View File

@@ -3273,8 +3273,8 @@ func Test_setcmdline()
call assert_equal(a:pos, getcmdpos()) call assert_equal(a:pos, getcmdpos())
call assert_fails('call setcmdline("' .. a:text .. '", -1)', 'E487:') call assert_fails('call setcmdline("' .. a:text .. '", -1)', 'E487:')
call assert_fails('call setcmdline({}, 0)', 'E928:') call assert_fails('call setcmdline({}, 0)', 'E1174:')
call assert_fails('call setcmdline("' .. a:text .. '", {})', 'E728:') call assert_fails('call setcmdline("' .. a:text .. '", {})', 'E1210:')
return '' return ''
endfunc endfunc

View File

@@ -3659,8 +3659,8 @@ enddef
def Test_setcmdline() def Test_setcmdline()
v9.CheckDefAndScriptSuccess(['setcmdline("ls", 2)']) v9.CheckDefAndScriptSuccess(['setcmdline("ls", 2)'])
v9.CheckDefAndScriptFailure(['setcmdline(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E928: String required']) v9.CheckDefAndScriptFailure(['setcmdline(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
v9.CheckDefAndScriptFailure(['setcmdline("ls", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1030: Using a String as a Number']) v9.CheckDefAndScriptFailure(['setcmdline("ls", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef enddef
def Test_setcmdpos() def Test_setcmdpos()

View File

@@ -707,6 +707,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
299,
/**/ /**/
298, 298,
/**/ /**/