mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Problem: Vim9: cannot use line break in :execute, :echomsg and :echoerr argument. Solution: Check for line break.
This commit is contained in:
12
src/eval.c
12
src/eval.c
@@ -207,14 +207,17 @@ eval_to_bool(
|
||||
* Call eval1() and give an error message if not done at a lower level.
|
||||
*/
|
||||
static int
|
||||
eval1_emsg(char_u **arg, typval_T *rettv, int evaluate)
|
||||
eval1_emsg(char_u **arg, typval_T *rettv, exarg_T *eap)
|
||||
{
|
||||
char_u *start = *arg;
|
||||
int ret;
|
||||
int did_emsg_before = did_emsg;
|
||||
int called_emsg_before = called_emsg;
|
||||
evalarg_T evalarg;
|
||||
|
||||
ret = eval1(arg, rettv, evaluate ? &EVALARG_EVALUATE : NULL);
|
||||
fill_evalarg_from_eap(&evalarg, eap, eap != NULL && eap->skip);
|
||||
|
||||
ret = eval1(arg, rettv, &evalarg);
|
||||
if (ret == FAIL)
|
||||
{
|
||||
// Report the invalid expression unless the expression evaluation has
|
||||
@@ -225,6 +228,7 @@ eval1_emsg(char_u **arg, typval_T *rettv, int evaluate)
|
||||
&& called_emsg == called_emsg_before)
|
||||
semsg(_(e_invexpr2), start);
|
||||
}
|
||||
clear_evalarg(&evalarg, eap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -294,7 +298,7 @@ eval_expr_typval(typval_T *expr, typval_T *argv, int argc, typval_T *rettv)
|
||||
if (s == NULL)
|
||||
return FAIL;
|
||||
s = skipwhite(s);
|
||||
if (eval1_emsg(&s, rettv, TRUE) == FAIL)
|
||||
if (eval1_emsg(&s, rettv, NULL) == FAIL)
|
||||
return FAIL;
|
||||
if (*s != NUL) // check for trailing chars after expr
|
||||
{
|
||||
@@ -5330,7 +5334,7 @@ ex_execute(exarg_T *eap)
|
||||
++emsg_skip;
|
||||
while (!ends_excmd2(eap->cmd, arg) || *arg == '"')
|
||||
{
|
||||
ret = eval1_emsg(&arg, &rettv, !eap->skip);
|
||||
ret = eval1_emsg(&arg, &rettv, eap);
|
||||
if (ret == FAIL)
|
||||
break;
|
||||
|
||||
|
@@ -1294,6 +1294,19 @@ def Test_execute_cmd()
|
||||
call CheckDefFailure(['execute "cmd"# comment'], 'E488:')
|
||||
enddef
|
||||
|
||||
def Test_execute_cmd_vimscript()
|
||||
" only checks line continuation
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
execute 'g:someVar'
|
||||
.. ' = ' ..
|
||||
'28'
|
||||
assert_equal(28, g:someVar)
|
||||
unlet g:someVar
|
||||
END
|
||||
CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_echo_cmd()
|
||||
echo 'some' # comment
|
||||
echon 'thing'
|
||||
@@ -1321,6 +1334,18 @@ def Test_echomsg_cmd()
|
||||
call CheckDefFailure(['echomsg "xxx"# comment'], 'E488:')
|
||||
enddef
|
||||
|
||||
def Test_echomsg_cmd_vimscript()
|
||||
" only checks line continuation
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
echomsg 'here'
|
||||
.. ' is ' ..
|
||||
'a message'
|
||||
assert_match('^here is a message$', Screenline(&lines))
|
||||
END
|
||||
CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_echoerr_cmd()
|
||||
try
|
||||
echoerr 'something' 'wrong' # comment
|
||||
@@ -1329,6 +1354,21 @@ def Test_echoerr_cmd()
|
||||
endtry
|
||||
enddef
|
||||
|
||||
def Test_echoerr_cmd_vimscript()
|
||||
" only checks line continuation
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
try
|
||||
echoerr 'this'
|
||||
.. ' is ' ..
|
||||
'wrong'
|
||||
catch
|
||||
assert_match('this is wrong', v:exception)
|
||||
endtry
|
||||
END
|
||||
CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
def Test_for_outside_of_function()
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
|
@@ -754,6 +754,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1100,
|
||||
/**/
|
||||
1099,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user