patch 9.2.0463: Not able to use legacy expression evaluation in a vim9script 
maps

Commit: 
https://github.com/vim/vim/commit/6b8d2262d3e94d5f4fdbe29ea621946f2718fe53
Author: Yegappan Lakshmanan <[email protected]>
Date:   Sun May 10 16:41:35 2026 +0000

    patch 9.2.0463: Not able to use legacy expression evaluation in a 
vim9script maps
    
    Problem:  Not able to use legacy expression evaluation in a vim9script
              maps
    Solution: Explicitly set script version to 1 when the :legacy modifier has 
been
              used (Yegappan Lakshmanan).
    
    fixe:   #20176
    closes: #20177
    
    Signed-off-by: Yegappan Lakshmanan <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/map.c b/src/map.c
index 5f07ef4a8..1c0d0ac7f 100644
--- a/src/map.c
+++ b/src/map.c
@@ -277,6 +277,8 @@ map_add(
     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
@@ -871,6 +873,8 @@ do_map(
 #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;
@@ -1822,11 +1826,10 @@ eval_map_expr(
     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);
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index ce0589806..f90d71971 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -2145,5 +2145,16 @@ def Test_syntax_enable_clear()
   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
diff --git a/src/version.c b/src/version.c
index fd79c4354..1e9a692ea 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    463,
 /**/
     462,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1wM7Vc-00Fevk-SH%40256bit.org.

Raspunde prin e-mail lui