Patch 8.2.4867
Problem:    Listing of mapping with K_SPECIAL is wrong.
Solution:   Adjust escaping of special characters. (closes #10351)
Files:      src/map.c, src/message.c, src/testdir/test_mapping.vim


*** ../vim-8.2.4866/src/map.c   2022-05-04 15:40:16.032317666 +0100
--- src/map.c   2022-05-04 18:44:26.443261501 +0100
***************
*** 189,205 ****
      if (*mp->m_str == NUL)
        msg_puts_attr("<Nop>", HL_ATTR(HLF_8));
      else
!     {
!       // Remove escaping of CSI, because "m_str" is in a format to be used
!       // as typeahead.
!       char_u *s = vim_strsave(mp->m_str);
!       if (s != NULL)
!       {
!           vim_unescape_csi(s);
!           msg_outtrans_special(s, FALSE, 0);
!           vim_free(s);
!       }
!     }
  #ifdef FEAT_EVAL
      if (p_verbose > 0)
        last_set_msg(mp->m_script_ctx);
--- 189,195 ----
      if (*mp->m_str == NUL)
        msg_puts_attr("<Nop>", HL_ATTR(HLF_8));
      else
!       msg_outtrans_special(mp->m_str, FALSE, 0);
  #ifdef FEAT_EVAL
      if (p_verbose > 0)
        last_set_msg(mp->m_script_ctx);
*** ../vim-8.2.4866/src/message.c       2022-03-22 20:42:09.174172862 +0000
--- src/message.c       2022-05-04 18:44:26.443261501 +0100
***************
*** 1800,1818 ****
  
      if (has_mbyte && !IS_SPECIAL(c))
      {
!       int len = (*mb_ptr2len)(str);
  
!       // For multi-byte characters check for an illegal byte.
!       if (MB_BYTE2LEN(*str) > len)
        {
!           transchar_nonprint(curbuf, buf, c);
!           *sp = str + 1;
!           return buf;
        }
        // Since 'special' is TRUE the multi-byte character 'c' will be
        // processed by get_special_key_name()
!       c = (*mb_ptr2char)(str);
!       *sp = str + len;
      }
      else
        *sp = str + 1;
--- 1800,1828 ----
  
      if (has_mbyte && !IS_SPECIAL(c))
      {
!       char_u  *p;
  
!       *sp = str;
!       // Try to un-escape a multi-byte character after modifiers.
!       p = mb_unescape(sp);
! 
!       if (p == NULL)
        {
!           int len = (*mb_ptr2len)(str);
! 
!           // Check for an illegal byte.
!           if (MB_BYTE2LEN(*str) > len)
!           {
!               transchar_nonprint(curbuf, buf, c);
!               *sp = str + 1;
!               return buf;
!           }
!           *sp = str + len;
!           p = str;
        }
        // Since 'special' is TRUE the multi-byte character 'c' will be
        // processed by get_special_key_name()
!       c = (*mb_ptr2char)(p);
      }
      else
        *sp = str + 1;
*** ../vim-8.2.4866/src/testdir/test_mapping.vim        2022-05-02 
22:53:41.384211031 +0100
--- src/testdir/test_mapping.vim        2022-05-04 18:44:26.443261501 +0100
***************
*** 482,487 ****
--- 482,507 ----
    call assert_match("\tLast set from .*/test_mapping.vim line \\d\\+$",
          \ execute('verbose map ,n')->trim()->split("\n")[1])
  
+   " character with K_SPECIAL byte in rhs
+   nmap foo …
+   call assert_equal(['n  foo           …'],
+         \ execute('nmap foo')->trim()->split("\n"))
+ 
+   " modified character with K_SPECIAL byte in rhs
+   nmap foo <M-…>
+   call assert_equal(['n  foo           <M-…>'],
+         \ execute('nmap foo')->trim()->split("\n"))
+ 
+   " character with K_SPECIAL byte in lhs
+   nmap … foo
+   call assert_equal(['n  …             foo'],
+         \ execute('nmap …')->trim()->split("\n"))
+ 
+   " modified character with K_SPECIAL byte in lhs
+   nmap <M-…> foo
+   call assert_equal(['n  <M-…>         foo'],
+         \ execute('nmap <M-…>')->trim()->split("\n"))
+ 
    " map to CTRL-V
    exe "nmap ,k \<C-V>"
    call assert_equal(['n  ,k            <Nop>'],
*** ../vim-8.2.4866/src/version.c       2022-05-04 18:12:51.217336786 +0100
--- src/version.c       2022-05-04 18:45:36.807158600 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4867,
  /**/

-- 
>From "know your smileys":
 C=}>;*{)) Drunk, devilish chef with a toupee in an updraft,
           a mustache, and a double chin

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            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/20220504175220.58BDE1C19BB%40moolenaar.net.

Raspunde prin e-mail lui