forked from aniani/vim
patch 8.2.1326: Vim9: skipping over white space after list
Problem: Vim9: skipping over white space after list. Solution: Do not skip white space, a following [] would be misinterpreted. (closes #6552) Fix a few side effects.
This commit is contained in:
parent
ea2d8d2571
commit
9d48956681
@ -838,6 +838,10 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
|
||||
: eval1(arg, &tvkey, evalarg)) == FAIL) // recursive!
|
||||
goto failret;
|
||||
|
||||
// The colon should come right after the key, but this wasn't checked
|
||||
// previously, so only require it in Vim9 script.
|
||||
if (!vim9script)
|
||||
*arg = skipwhite(*arg);
|
||||
if (**arg != ':')
|
||||
{
|
||||
if (evaluate)
|
||||
|
41
src/eval.c
41
src/eval.c
@ -1913,27 +1913,28 @@ eval_func(
|
||||
char_u *
|
||||
eval_next_non_blank(char_u *arg, evalarg_T *evalarg, int *getnext)
|
||||
{
|
||||
char_u *p = skipwhite(arg);
|
||||
|
||||
*getnext = FALSE;
|
||||
if (in_vim9script()
|
||||
&& evalarg != NULL
|
||||
&& (evalarg->eval_cookie != NULL || evalarg->eval_cctx != NULL)
|
||||
&& (*arg == NUL || (VIM_ISWHITE(arg[-1])
|
||||
&& vim9_comment_start(arg))))
|
||||
&& (*p == NUL || (VIM_ISWHITE(p[-1]) && vim9_comment_start(p))))
|
||||
{
|
||||
char_u *p;
|
||||
char_u *next;
|
||||
|
||||
if (evalarg->eval_cookie != NULL)
|
||||
p = getline_peek(evalarg->eval_getline, evalarg->eval_cookie);
|
||||
next = getline_peek(evalarg->eval_getline, evalarg->eval_cookie);
|
||||
else
|
||||
p = peek_next_line_from_context(evalarg->eval_cctx);
|
||||
next = peek_next_line_from_context(evalarg->eval_cctx);
|
||||
|
||||
if (p != NULL)
|
||||
if (next != NULL)
|
||||
{
|
||||
*getnext = TRUE;
|
||||
return skipwhite(p);
|
||||
return skipwhite(next);
|
||||
}
|
||||
}
|
||||
return arg;
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2039,6 +2040,7 @@ eval0(
|
||||
|
||||
p = skipwhite(arg);
|
||||
ret = eval1(&p, rettv, evalarg);
|
||||
p = skipwhite(p);
|
||||
|
||||
if (ret == FAIL || !ends_excmd2(arg, p))
|
||||
{
|
||||
@ -2107,6 +2109,8 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
|
||||
if (getnext)
|
||||
*arg = eval_next_line(evalarg_used);
|
||||
else
|
||||
*arg = p;
|
||||
|
||||
result = FALSE;
|
||||
if (evaluate)
|
||||
@ -2142,6 +2146,8 @@ eval1(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
}
|
||||
if (getnext)
|
||||
*arg = eval_next_line(evalarg_used);
|
||||
else
|
||||
*arg = p;
|
||||
|
||||
/*
|
||||
* Get the third variable. Recursive!
|
||||
@ -2234,6 +2240,8 @@ eval2(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
{
|
||||
if (getnext)
|
||||
*arg = eval_next_line(evalarg_used);
|
||||
else
|
||||
*arg = p;
|
||||
|
||||
/*
|
||||
* Get the second variable.
|
||||
@ -2349,6 +2357,8 @@ eval3(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
{
|
||||
if (getnext)
|
||||
*arg = eval_next_line(evalarg_used);
|
||||
else
|
||||
*arg = p;
|
||||
|
||||
/*
|
||||
* Get the second variable.
|
||||
@ -2575,6 +2585,8 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
|
||||
if (getnext)
|
||||
*arg = eval_next_line(evalarg);
|
||||
else
|
||||
*arg = p;
|
||||
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
||||
if ((op != '+' || (rettv->v_type != VAR_LIST
|
||||
&& rettv->v_type != VAR_BLOB))
|
||||
@ -2756,6 +2768,7 @@ eval6(
|
||||
int evaluate;
|
||||
int getnext;
|
||||
typval_T var2;
|
||||
char_u *p;
|
||||
int op;
|
||||
varnumber_T n1, n2;
|
||||
#ifdef FEAT_FLOAT
|
||||
@ -2763,12 +2776,15 @@ eval6(
|
||||
#endif
|
||||
int error;
|
||||
|
||||
op = *eval_next_non_blank(*arg, evalarg, &getnext);
|
||||
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
||||
op = *p;
|
||||
if (op != '*' && op != '/' && op != '%')
|
||||
break;
|
||||
|
||||
if (getnext)
|
||||
*arg = eval_next_line(evalarg);
|
||||
else
|
||||
*arg = p;
|
||||
|
||||
#ifdef FEAT_FLOAT
|
||||
f1 = 0;
|
||||
@ -3115,8 +3131,6 @@ eval7(
|
||||
vim_free(alias);
|
||||
}
|
||||
|
||||
*arg = skipwhite(*arg);
|
||||
|
||||
// Handle following '[', '(' and '.' for expr[expr], expr.name,
|
||||
// expr(expr), expr->name(expr)
|
||||
if (ret == OK)
|
||||
@ -5152,7 +5166,7 @@ handle_subscript(
|
||||
p = eval_next_non_blank(*arg, evalarg, &getnext);
|
||||
if (getnext
|
||||
&& ((rettv->v_type == VAR_DICT && *p == '.' && eval_isdictc(p[1]))
|
||||
|| (*p == '-' && p[1] == '>'
|
||||
|| (p[0] == '-' && p[1] == '>'
|
||||
&& (p[2] == '{' || ASCII_ISALPHA(p[2])))))
|
||||
{
|
||||
*arg = eval_next_line(evalarg);
|
||||
@ -5178,8 +5192,9 @@ handle_subscript(
|
||||
dict_unref(selfdict);
|
||||
selfdict = NULL;
|
||||
}
|
||||
else if (**arg == '-' && (*arg)[1] == '>')
|
||||
else if (p[0] == '-' && p[1] == '>')
|
||||
{
|
||||
*arg = p;
|
||||
if (ret == OK)
|
||||
{
|
||||
if ((*arg)[2] == '{')
|
||||
|
@ -1199,7 +1199,7 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
|
||||
had_comma = **arg == ',';
|
||||
if (had_comma)
|
||||
{
|
||||
if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
|
||||
if (vim9script && !IS_WHITE_OR_NUL((*arg)[1]))
|
||||
{
|
||||
semsg(_(e_white_after), ",");
|
||||
goto failret;
|
||||
@ -1231,7 +1231,7 @@ failret:
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
*arg = skipwhite(*arg + 1);
|
||||
*arg += 1;
|
||||
if (evaluate)
|
||||
rettv_list_set(rettv, l);
|
||||
|
||||
|
@ -1355,7 +1355,7 @@ func Test_input_func()
|
||||
func! Tcomplete(arglead, cmdline, pos)
|
||||
return "item1\nitem2\nitem3"
|
||||
endfunc
|
||||
call feedkeys(":let c = input('Q? ', '' , 'custom,Tcomplete')\<CR>"
|
||||
call feedkeys(":let c = input('Q? ', '', 'custom,Tcomplete')\<CR>"
|
||||
\ .. "\<C-A>\<CR>", 'xt')
|
||||
delfunc Tcomplete
|
||||
call assert_equal('item1 item2 item3', c)
|
||||
|
@ -120,7 +120,7 @@ func Test_gn_command()
|
||||
sil! %d_
|
||||
|
||||
" search using the \zs atom
|
||||
call setline(1, [' nnoremap', '' , 'nnoremap'])
|
||||
call setline(1, [' nnoremap', '', 'nnoremap'])
|
||||
set wrapscan&vim
|
||||
let @/ = '\_s\zsnnoremap'
|
||||
$
|
||||
|
@ -588,7 +588,7 @@ func Test_popup_drag_termwin()
|
||||
call setline(1, range(100))
|
||||
for nr in range(7)
|
||||
call setline(nr * 12 + 1, "fold {{{")
|
||||
call setline(nr * 12 + 11 , "end }}}")
|
||||
call setline(nr * 12 + 11, "end }}}")
|
||||
endfor
|
||||
%foldclose
|
||||
set shell=/bin/sh noruler
|
||||
|
@ -350,7 +350,7 @@ function Test_tabpage_with_tabprevious()
|
||||
call Check_tab_count(6, cmd . ' 3', 3)
|
||||
call Check_tab_count(6, cmd . ' 8', 4)
|
||||
for n in range(2)
|
||||
for c in ['0', '.+3', '+', '+2' , '-', '-2' , '$', '+99', '-99']
|
||||
for c in ['0', '.+3', '+', '+2', '-', '-2', '$', '+99', '-99']
|
||||
if n == 0 " pre count
|
||||
let entire_cmd = c . cmd
|
||||
let err_code = 'E16:'
|
||||
|
@ -201,28 +201,28 @@ func Test_match()
|
||||
call assert_equal("c", matchstr("abcd", ".", 2, 0))
|
||||
call assert_equal("a", matchstr("abcd", ".", 0, -1))
|
||||
call assert_equal(-1, match("abcd", ".", 0, 5))
|
||||
call assert_equal(0 , match("abcd", ".", 0, -1))
|
||||
call assert_equal(0 , match('abc', '.', 0, 1))
|
||||
call assert_equal(1 , match('abc', '.', 0, 2))
|
||||
call assert_equal(2 , match('abc', '.', 0, 3))
|
||||
call assert_equal(0, match("abcd", ".", 0, -1))
|
||||
call assert_equal(0, match('abc', '.', 0, 1))
|
||||
call assert_equal(1, match('abc', '.', 0, 2))
|
||||
call assert_equal(2, match('abc', '.', 0, 3))
|
||||
call assert_equal(-1, match('abc', '.', 0, 4))
|
||||
call assert_equal(1 , match('abc', '.', 1, 1))
|
||||
call assert_equal(2 , match('abc', '.', 2, 1))
|
||||
call assert_equal(1, match('abc', '.', 1, 1))
|
||||
call assert_equal(2, match('abc', '.', 2, 1))
|
||||
call assert_equal(-1, match('abc', '.', 3, 1))
|
||||
call assert_equal(3 , match('abc', '$', 0, 1))
|
||||
call assert_equal(3, match('abc', '$', 0, 1))
|
||||
call assert_equal(-1, match('abc', '$', 0, 2))
|
||||
call assert_equal(3 , match('abc', '$', 1, 1))
|
||||
call assert_equal(3 , match('abc', '$', 2, 1))
|
||||
call assert_equal(3 , match('abc', '$', 3, 1))
|
||||
call assert_equal(3, match('abc', '$', 1, 1))
|
||||
call assert_equal(3, match('abc', '$', 2, 1))
|
||||
call assert_equal(3, match('abc', '$', 3, 1))
|
||||
call assert_equal(-1, match('abc', '$', 4, 1))
|
||||
call assert_equal(0 , match('abc', '\zs', 0, 1))
|
||||
call assert_equal(1 , match('abc', '\zs', 0, 2))
|
||||
call assert_equal(2 , match('abc', '\zs', 0, 3))
|
||||
call assert_equal(3 , match('abc', '\zs', 0, 4))
|
||||
call assert_equal(0, match('abc', '\zs', 0, 1))
|
||||
call assert_equal(1, match('abc', '\zs', 0, 2))
|
||||
call assert_equal(2, match('abc', '\zs', 0, 3))
|
||||
call assert_equal(3, match('abc', '\zs', 0, 4))
|
||||
call assert_equal(-1, match('abc', '\zs', 0, 5))
|
||||
call assert_equal(1 , match('abc', '\zs', 1, 1))
|
||||
call assert_equal(2 , match('abc', '\zs', 2, 1))
|
||||
call assert_equal(3 , match('abc', '\zs', 3, 1))
|
||||
call assert_equal(1, match('abc', '\zs', 1, 1))
|
||||
call assert_equal(2, match('abc', '\zs', 2, 1))
|
||||
call assert_equal(3, match('abc', '\zs', 3, 1))
|
||||
call assert_equal(-1, match('abc', '\zs', 4, 1))
|
||||
endfunc
|
||||
|
||||
|
@ -1219,7 +1219,7 @@ func Test_prop_func_invalid_args()
|
||||
call assert_fails('call prop_find({}, "x")', 'E474:')
|
||||
call assert_fails('call prop_find({"lnum" : -2})', 'E16:')
|
||||
call assert_fails('call prop_list(1, [])', 'E715:')
|
||||
call assert_fails('call prop_list(-1 , {})', 'E16:')
|
||||
call assert_fails('call prop_list(-1, {})', 'E16:')
|
||||
call assert_fails('call prop_remove([])', 'E474:')
|
||||
call assert_fails('call prop_remove({}, -2)', 'E16:')
|
||||
call assert_fails('call prop_remove({})', 'E968:')
|
||||
|
@ -642,6 +642,10 @@ get_func_tv(
|
||||
break;
|
||||
}
|
||||
++argcount;
|
||||
// The comma should come right after the argument, but this wasn't
|
||||
// checked previously, thus only enforce it in Vim9 script.
|
||||
if (!in_vim9script())
|
||||
argp = skipwhite(argp);
|
||||
if (*argp != ',')
|
||||
break;
|
||||
}
|
||||
|
@ -754,6 +754,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1326,
|
||||
/**/
|
||||
1325,
|
||||
/**/
|
||||
|
Loading…
x
Reference in New Issue
Block a user