mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.2.0341: using ":for" in Vim9 script gives an error
Problem: Using ":for" in Vim9 script gives an error. Solution: Pass the LET_NO_COMMAND flag. (closes #5715)
This commit is contained in:
@@ -1491,6 +1491,8 @@ next_for_item(void *fi_void, char_u *arg)
|
|||||||
{
|
{
|
||||||
forinfo_T *fi = (forinfo_T *)fi_void;
|
forinfo_T *fi = (forinfo_T *)fi_void;
|
||||||
int result;
|
int result;
|
||||||
|
int flag = current_sctx.sc_version == SCRIPT_VERSION_VIM9 ?
|
||||||
|
LET_NO_COMMAND : 0;
|
||||||
listitem_T *item;
|
listitem_T *item;
|
||||||
|
|
||||||
if (fi->fi_blob != NULL)
|
if (fi->fi_blob != NULL)
|
||||||
@@ -1504,7 +1506,7 @@ next_for_item(void *fi_void, char_u *arg)
|
|||||||
tv.vval.v_number = blob_get(fi->fi_blob, fi->fi_bi);
|
tv.vval.v_number = blob_get(fi->fi_blob, fi->fi_bi);
|
||||||
++fi->fi_bi;
|
++fi->fi_bi;
|
||||||
return ex_let_vars(arg, &tv, TRUE, fi->fi_semicolon,
|
return ex_let_vars(arg, &tv, TRUE, fi->fi_semicolon,
|
||||||
fi->fi_varcount, 0, NULL) == OK;
|
fi->fi_varcount, flag, NULL) == OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
item = fi->fi_lw.lw_item;
|
item = fi->fi_lw.lw_item;
|
||||||
@@ -1514,7 +1516,7 @@ next_for_item(void *fi_void, char_u *arg)
|
|||||||
{
|
{
|
||||||
fi->fi_lw.lw_item = item->li_next;
|
fi->fi_lw.lw_item = item->li_next;
|
||||||
result = (ex_let_vars(arg, &item->li_tv, TRUE, fi->fi_semicolon,
|
result = (ex_let_vars(arg, &item->li_tv, TRUE, fi->fi_semicolon,
|
||||||
fi->fi_varcount, 0, NULL) == OK);
|
fi->fi_varcount, flag, NULL) == OK);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -775,5 +775,19 @@ def Test_echo_cmd()
|
|||||||
assert_match('^some more$', Screenline(&lines))
|
assert_match('^some more$', Screenline(&lines))
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_for_outside_of_function()
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
new
|
||||||
|
for var in range(0, 3)
|
||||||
|
append(line('$'), var)
|
||||||
|
endfor
|
||||||
|
assert_equal(['', '0', '1', '2', '3'], getline(1, '$'))
|
||||||
|
bwipe!
|
||||||
|
END
|
||||||
|
writefile(lines, 'Xvim9for.vim')
|
||||||
|
source Xvim9for.vim
|
||||||
|
delete('Xvim9for.vim')
|
||||||
|
enddef
|
||||||
|
|
||||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||||
|
@@ -738,6 +738,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 */
|
||||||
|
/**/
|
||||||
|
341,
|
||||||
/**/
|
/**/
|
||||||
340,
|
340,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user