diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-10-23 12:34:27 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-10-23 12:34:27 +0100 |
commit | ee56f3f119c4378a5b62b4d504cff3373b363308 (patch) | |
tree | cf21fac7b70069c8ccf1057a904ca0cb19699ee7 /src/ex_eval.c | |
parent | 079ba76ae7a7d0ef404cb9b41dff2663ff41f51b (diff) |
patch 8.2.3559: loop variable recreated every timev8.2.3559
Problem: Loop variable recreated every time.
Solution: Keep the loop variable when looping.
Diffstat (limited to 'src/ex_eval.c')
-rw-r--r-- | src/ex_eval.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ex_eval.c b/src/ex_eval.c index 1142280bae..1f66e336f6 100644 --- a/src/ex_eval.c +++ b/src/ex_eval.c @@ -1191,8 +1191,9 @@ ex_while(exarg_T *eap) & CSF_FUNC_DEF; // Any variables defined in the previous round are no longer - // visible. - for (i = cstack->cs_script_var_len[cstack->cs_idx]; + // visible. Keep the first one, it is the loop variable that + // we reuse every time around. + for (i = cstack->cs_script_var_len[cstack->cs_idx] + 1; i < si->sn_var_vals.ga_len; ++i) { svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + i; |