forked from aniani/vim
patch 8.2.2079: Vim9: cannot put a linebreak before or after "in" of ":for"
Problem: Vim9: cannot put a linebreak before or after "in" of ":for". Solution: Skip over linebreak.
This commit is contained in:
@@ -1849,6 +1849,28 @@ def Test_for_loop()
|
|||||||
concat ..= str
|
concat ..= str
|
||||||
endfor
|
endfor
|
||||||
assert_equal('onetwo', concat)
|
assert_equal('onetwo', concat)
|
||||||
|
|
||||||
|
var total = 0
|
||||||
|
for nr in
|
||||||
|
[1, 2, 3]
|
||||||
|
total += nr
|
||||||
|
endfor
|
||||||
|
assert_equal(6, total)
|
||||||
|
|
||||||
|
total = 0
|
||||||
|
for nr
|
||||||
|
in [1, 2, 3]
|
||||||
|
total += nr
|
||||||
|
endfor
|
||||||
|
assert_equal(6, total)
|
||||||
|
|
||||||
|
total = 0
|
||||||
|
for nr
|
||||||
|
in
|
||||||
|
[1, 2, 3]
|
||||||
|
total += nr
|
||||||
|
endfor
|
||||||
|
assert_equal(6, total)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_for_loop_fails()
|
def Test_for_loop_fails()
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
2079,
|
||||||
/**/
|
/**/
|
||||||
2078,
|
2078,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -6486,6 +6486,7 @@ compile_for(char_u *arg_start, cctx_T *cctx)
|
|||||||
char_u *arg_end;
|
char_u *arg_end;
|
||||||
char_u *name = NULL;
|
char_u *name = NULL;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
char_u *wp;
|
||||||
int var_count = 0;
|
int var_count = 0;
|
||||||
int semicolon = FALSE;
|
int semicolon = FALSE;
|
||||||
size_t varlen;
|
size_t varlen;
|
||||||
@@ -6503,13 +6504,19 @@ compile_for(char_u *arg_start, cctx_T *cctx)
|
|||||||
var_count = 1;
|
var_count = 1;
|
||||||
|
|
||||||
// consume "in"
|
// consume "in"
|
||||||
|
wp = p;
|
||||||
p = skipwhite(p);
|
p = skipwhite(p);
|
||||||
if (STRNCMP(p, "in", 2) != 0 || !VIM_ISWHITE(p[2]))
|
if (may_get_next_line_error(wp, &p, cctx) == FAIL)
|
||||||
|
return NULL;
|
||||||
|
if (STRNCMP(p, "in", 2) != 0 || !IS_WHITE_OR_NUL(p[2]))
|
||||||
{
|
{
|
||||||
emsg(_(e_missing_in));
|
emsg(_(e_missing_in));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = skipwhite(p + 2);
|
wp = p + 2;
|
||||||
|
p = skipwhite(wp);
|
||||||
|
if (may_get_next_line_error(wp, &p, cctx) == FAIL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
scope = new_scope(cctx, FOR_SCOPE);
|
scope = new_scope(cctx, FOR_SCOPE);
|
||||||
if (scope == NULL)
|
if (scope == NULL)
|
||||||
|
Reference in New Issue
Block a user