aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_eval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-14 13:49:28 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-14 16:10:09 +0800
commit8729c41f44de3b164ad8d01bb3558c6400e27952 (patch)
tree9c611cef6c60a7522e9cbaf47d90a8c937f9a385 /src/nvim/ex_eval.c
parent4b84b2e2aa3d7ab6a4e346c7439826700682f5f1 (diff)
downloadrneovim-8729c41f44de3b164ad8d01bb3558c6400e27952.tar.gz
rneovim-8729c41f44de3b164ad8d01bb3558c6400e27952.tar.bz2
rneovim-8729c41f44de3b164ad8d01bb3558c6400e27952.zip
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. https://github.com/vim/vim/commit/b7a78f7a6713f07d2fcad0b27dea22925c7b1cdf Omit *_break_count and skip_for_lines(): Vim9 script only. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/ex_eval.c')
-rw-r--r--src/nvim/ex_eval.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 27f012a4ab..34015728b0 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -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