{
if (evalarg != NULL)
{
- if (evalarg->eval_tofree != NULL)
+ garray_T *etga = &evalarg->eval_tofree_ga;
+
+ if (evalarg->eval_tofree != NULL || evalarg->eval_using_cmdline)
{
if (eap != NULL)
{
// We may need to keep the original command line, e.g. for
- // ":let" it has the variable names. But we may also need the
- // new one, "nextcmd" points into it. Keep both.
+ // ":let" it has the variable names. But we may also need
+ // the new one, "nextcmd" points into it. Keep both.
vim_free(eap->cmdline_tofree);
eap->cmdline_tofree = *eap->cmdlinep;
- *eap->cmdlinep = evalarg->eval_tofree;
+
+ if (evalarg->eval_using_cmdline && etga->ga_len > 0)
+ {
+ // "nextcmd" points into the last line in eval_tofree_ga,
+ // need to keep it around.
+ --etga->ga_len;
+ *eap->cmdlinep = ((char_u **)etga->ga_data)[etga->ga_len];
+ }
+ else
+ *eap->cmdlinep = evalarg->eval_tofree;
}
else
vim_free(evalarg->eval_tofree);
evalarg->eval_tofree = NULL;
}
- ga_clear_strings(&evalarg->eval_tofree_ga);
+ ga_clear_strings(etga);
VIM_CLEAR(evalarg->eval_tofree_lambda);
}
}
v9.CheckDefAndScriptFailure(lines, 'E488: Trailing characters: | echo')
enddef
+def Test_lambda_with_following_cmd()
+ var lines =<< trim END
+ set ts=2
+ var Lambda = () => {
+ set ts=4
+ } | set ts=3
+ assert_equal(3, &ts)
+ Lambda()
+ assert_equal(4, &ts)
+ END
+ v9.CheckDefAndScriptSuccess(lines)
+ set ts=8
+enddef
+
def Test_pass_legacy_lambda_to_def_func()
var lines =<< trim END
vim9script
{
type = lvar.lv_type;
idx = lvar.lv_idx;
- outer_loop_depth = lvar.lv_loop_depth;
- outer_loop_idx = lvar.lv_loop_idx;
if (lvar.lv_from_outer != 0)
+ {
gen_load_outer = lvar.lv_from_outer;
+ outer_loop_depth = lvar.lv_loop_depth;
+ outer_loop_idx = lvar.lv_loop_idx;
+ }
else
gen_load = TRUE;
}
*arg = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum]
+ off;
+ evalarg.eval_using_cmdline = FALSE;
}
clear_evalarg(&evalarg, NULL);