vim-patch:8.2.1080: Vim9: no line break allowed in a for loop

Problem:    Vim9: no line break allowed in a for loop.
Solution:   Skip line breaks in for command.

b7a78f7a67

Omit *_break_count and skip_for_lines(): Vim9 script only.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-04-14 13:49:28 +08:00
parent 4b84b2e2aa
commit 8729c41f44
7 changed files with 51 additions and 25 deletions

View File

@@ -794,11 +794,17 @@ void ex_eval(exarg_T *eap)
typval_T tv;
evalarg_T evalarg = {
.eval_flags = eap->skip ? 0 : EVAL_EVALUATE,
.eval_cookie = eap->getline == getsourceline ? eap->cookie : NULL,
};
if (getline_equal(eap->getline, eap->cookie, getsourceline)) {
evalarg.eval_getline = eap->getline;
evalarg.eval_cookie = eap->cookie;
}
if (eval0(eap->arg, &tv, eap, &evalarg) == OK) {
tv_clear(&tv);
}
clear_evalarg(&evalarg, eap);
}
/// Handle ":if".
@@ -961,6 +967,14 @@ void ex_while(exarg_T *eap)
} else {
void *fi;
evalarg_T evalarg = {
.eval_flags = eap->skip ? 0 : EVAL_EVALUATE,
};
if (getline_equal(eap->getline, eap->cookie, getsourceline)) {
evalarg.eval_getline = eap->getline;
evalarg.eval_cookie = eap->cookie;
}
// ":for var in list-expr"
if ((cstack->cs_lflags & CSL_HAD_LOOP) != 0) {
// Jumping here from a ":continue" or ":endfor": use the
@@ -969,7 +983,7 @@ void ex_while(exarg_T *eap)
error = false;
} else {
// Evaluate the argument and get the info in a structure.
fi = eval_for_line(eap->arg, &error, eap, skip);
fi = eval_for_line(eap->arg, &error, eap, &evalarg);
cstack->cs_forinfo[cstack->cs_idx] = fi;
}
@@ -984,6 +998,7 @@ void ex_while(exarg_T *eap)
free_for_info(fi);
cstack->cs_forinfo[cstack->cs_idx] = NULL;
}
clear_evalarg(&evalarg, eap);
}
// If this cstack entry was just initialised and is active, set the