Patch 8.2.2074
Problem:    Vim9: using :normal from Vim9 script can't handle range.
Solution:   Execute a :normal command in legacy script context. (closes #7401)
Files:      src/structs.h, src/ex_docmd.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.2073/src/structs.h       2020-11-15 20:32:54.167882094 +0100
--- src/structs.h       2020-12-01 19:40:47.567677152 +0100
***************
*** 4155,4160 ****
--- 4155,4161 ----
      int               save_finish_op;
      int               save_opcount;
      int               save_reg_executing;
+     int               save_script_version;
      tasave_T  tabuf;
  } save_state_T;
  
*** ../vim-8.2.2073/src/ex_docmd.c      2020-11-30 21:12:15.747157517 +0100
--- src/ex_docmd.c      2020-12-01 20:09:09.256981924 +0100
***************
*** 7994,8003 ****
      sst->save_finish_op = finish_op;
      sst->save_opcount = opcount;
      sst->save_reg_executing = reg_executing;
  
!     msg_scroll = FALSE;           // no msg scrolling in Normal mode
!     restart_edit = 0;     // don't go to Insert mode
!     p_im = FALSE;         // don't use 'insertmode'
  
      /*
       * Save the current typeahead.  This is required to allow using ":normal"
--- 7994,8005 ----
      sst->save_finish_op = finish_op;
      sst->save_opcount = opcount;
      sst->save_reg_executing = reg_executing;
+     sst->save_script_version = current_sctx.sc_version;
  
!     msg_scroll = FALSE;                   // no msg scrolling in Normal mode
!     restart_edit = 0;             // don't go to Insert mode
!     p_im = FALSE;                 // don't use 'insertmode'
!     current_sctx.sc_version = 1;    // not in Vim9 script
  
      /*
       * Save the current typeahead.  This is required to allow using ":normal"
***************
*** 8021,8026 ****
--- 8023,8029 ----
      opcount = sst->save_opcount;
      reg_executing = sst->save_reg_executing;
      msg_didout |= sst->save_msg_didout;       // don't reset msg_didout now
+     current_sctx.sc_version = sst->save_script_version;
  
      // Restore the state (needed when called from a function executed for
      // 'indentexpr'). Update the mouse and cursor, they may have changed.
*** ../vim-8.2.2073/src/testdir/test_vim9_script.vim    2020-12-01 
16:30:40.161598319 +0100
--- src/testdir/test_vim9_script.vim    2020-12-01 20:08:19.749218836 +0100
***************
*** 2958,2963 ****
--- 2958,2976 ----
    bwipe!
  enddef
  
+ def InvokeNormal()
+   exe "norm! :m+1\r"
+ enddef
+ 
+ def Test_invoke_normal_in_visual_mode()
+   xnoremap <F3> <Cmd>call <SID>InvokeNormal()<CR>
+   new
+   setline(1, ['aaa', 'bbb'])
+   feedkeys("V\<F3>", 'xt')
+   assert_equal(['bbb', 'aaa'], getline(1, 2))
+   xunmap <F3>
+ enddef
+ 
  " Keep this last, it messes up highlighting.
  def Test_substitute_cmd()
    new
*** ../vim-8.2.2073/src/version.c       2020-12-01 16:30:40.165598305 +0100
--- src/version.c       2020-12-01 20:07:21.473504964 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2074,
  /**/

-- 
The early bird gets the worm. The second mouse gets the cheese.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 on the web visit 
https://groups.google.com/d/msgid/vim_dev/202012011912.0B1JCueq3887430%40masaka.moolenaar.net.

Raspunde prin e-mail lui