else
{
mp->m_script_ctx = current_sctx;
+ if (cmdmod.cmod_flags & CMOD_LEGACY)
+ mp->m_script_ctx.sc_version = 1;
mp->m_script_ctx.sc_lnum += SOURCING_LNUM;
}
#endif
#ifdef FEAT_EVAL
mp->m_expr = expr;
mp->m_script_ctx = current_sctx;
+ if (cmdmod.cmod_flags & CMOD_LEGACY)
+ mp->m_script_ctx.sc_version = 1;
mp->m_script_ctx.sc_lnum += SOURCING_LNUM;
#endif
mp_result[keyround - 1] = mp;
save_cursor = curwin->w_cursor;
save_msg_col = msg_col;
save_msg_row = msg_row;
+
+ current_sctx.sc_version = mp->m_script_ctx.sc_version;
if (mp->m_script_ctx.sc_version == SCRIPT_VERSION_VIM9)
- {
current_sctx.sc_sid = mp->m_script_ctx.sc_sid;
- current_sctx.sc_version = SCRIPT_VERSION_VIM9;
- }
// Note: the evaluation may make "mp" invalid.
p = eval_to_string(expr, FALSE, FALSE);
syntax clear
enddef
+" Test for using legacy expression evaluation in a vim9script map
+def Test_map_legacy_expr()
+ var lines =<< trim END
+ legacy inoremap <expr> <F2> 'hello' . 'world'
+ new
+ feedkeys("a\<F2>", 'xt')
+ assert_equal(['helloworld'], getline(1, '$'))
+ bw!
+ END
+ v9.CheckDefAndScriptSuccess(lines)
+enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker