Patch 8.2.2005
Problem:    Redoing a mapping with <Cmd> doesn't work properly.
Solution:   Fill the redo buffer.  Use "<SNR>" instead of a key code.
            (closes #7282)
Files:      src/ops.c, src/getchar.c, src/testdir/test_mapping.vim


*** ../vim-8.2.2004/src/ops.c   2020-11-12 14:20:32.025927280 +0100
--- src/ops.c   2020-11-17 21:56:25.617238501 +0100
***************
*** 3465,3472 ****
        if ((redo_yank || oap->op_type != OP_YANK)
                && ((!VIsual_active || oap->motion_force)
                    // Also redo Operator-pending Visual mode mappings
!                   || (VIsual_active && cap->cmdchar == ':'
!                                                && oap->op_type != OP_COLON))
                && cap->cmdchar != 'D'
  #ifdef FEAT_FOLDING
                && oap->op_type != OP_FOLD
--- 3465,3473 ----
        if ((redo_yank || oap->op_type != OP_YANK)
                && ((!VIsual_active || oap->motion_force)
                    // Also redo Operator-pending Visual mode mappings
!                   || (VIsual_active
!                         && (cap->cmdchar == ':' || cap->cmdchar == K_COMMAND)
!                                                 && oap->op_type != OP_COLON))
                && cap->cmdchar != 'D'
  #ifdef FEAT_FOLDING
                && oap->op_type != OP_FOLD
***************
*** 3688,3694 ****
                            get_op_char(oap->op_type),
                            get_extra_op_char(oap->op_type),
                            oap->motion_force, cap->cmdchar, cap->nchar);
!               else if (cap->cmdchar != ':')
                {
                    int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;
  
--- 3689,3695 ----
                            get_op_char(oap->op_type),
                            get_extra_op_char(oap->op_type),
                            oap->motion_force, cap->cmdchar, cap->nchar);
!               else if (cap->cmdchar != ':' && cap->cmdchar != K_COMMAND)
                {
                    int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL;
  
*** ../vim-8.2.2004/src/getchar.c       2020-11-15 20:49:36.979163804 +0100
--- src/getchar.c       2020-11-17 22:18:15.222053492 +0100
***************
*** 3691,3701 ****
        else if (IS_SPECIAL(c1))
        {
            if (c1 == K_SNR)
!           {
!               ga_append(&line_ga, (char)K_SPECIAL);
!               ga_append(&line_ga, (char)KS_EXTRA);
!               ga_append(&line_ga, (char)KE_SNR);
!           }
            else
            {
                semsg(e_cmd_maping_must_not_include_str_key,
--- 3691,3697 ----
        else if (IS_SPECIAL(c1))
        {
            if (c1 == K_SNR)
!               ga_concat(&line_ga, (char_u *)"<SNR>");
            else
            {
                semsg(e_cmd_maping_must_not_include_str_key,
*** ../vim-8.2.2004/src/testdir/test_mapping.vim        2020-11-12 
14:20:32.025927280 +0100
--- src/testdir/test_mapping.vim        2020-11-18 11:33:42.554346535 +0100
***************
*** 1324,1327 ****
--- 1324,1363 ----
    %bw!
  endfunc
  
+ func Test_map_cmdkey_redo()
+   func SelectDash()
+     call search('^---\n\zs', 'bcW')
+     norm! V
+     call search('\n\ze---$', 'W')
+   endfunc
+ 
+   let text =<< trim END
+       ---
+       aaa
+       ---
+       bbb
+       bbb
+       ---
+       ccc
+       ccc
+       ccc
+       ---
+   END
+   new Xcmdtext
+   call setline(1, text)
+ 
+   onoremap <silent> i- <Cmd>call SelectDash()<CR>
+   call feedkeys('2Gdi-', 'xt')
+   call assert_equal(['---', '---'], getline(1, 2))
+   call feedkeys('j.', 'xt')
+   call assert_equal(['---', '---', '---'], getline(1, 3))
+   call feedkeys('j.', 'xt')
+   call assert_equal(['---', '---', '---', '---'], getline(1, 4))
+ 
+   bwipe!
+   call delete('Xcmdtext')
+   delfunc SelectDash
+   ounmap i-
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.2004/src/version.c       2020-11-17 19:56:05.534193964 +0100
--- src/version.c       2020-11-18 11:34:04.454275176 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2005,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
269. You receive an e-mail from the wife of a deceased president, offering
     to send you twenty million dollar, and you are not even surprised.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202011181035.0AIAZ3Gt1720180%40masaka.moolenaar.net.

Raspunde prin e-mail lui