]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0629: 0x80 and 0x9b byte not unescaped when check for valid abbr v9.2.0629
authorzeertzjq <zeertzjq@outlook.com>
Sat, 13 Jun 2026 15:59:45 +0000 (15:59 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 13 Jun 2026 15:59:45 +0000 (15:59 +0000)
Problem:  0x80 and 0x9b byte not unescaped when checking for valid abbr
          (Mao-Yining)
Solution: Use mb_unescape() (zeertzjq).

fixes:  #20506
closes: #20508

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/map.c
src/testdir/test_mapping.vim
src/version.c

index 34e465ec3f56b90fb3beda838cff40857d1f08be..50d7ee4bcb2ce6d52b7d24d33ccad1ffb06a5a92 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -662,18 +662,24 @@ do_map(
                {
                    int first, last;
                    int same = -1;
+                   char_u *p_char;
 
-                   first = vim_iswordp(keys);
+                   p = keys;
+                   p_char = mb_unescape(&p);
+                   if (p_char == NULL)
+                       p_char = p++;
+                   first = vim_iswordp(p_char);
                    last = first;
-                   p = keys + (*mb_ptr2len)(keys);
                    n = 1;
                    while (p < keys + len)
                    {
-                       ++n;                    // nr of (multi-byte) chars
-                       last = vim_iswordp(p);  // type of last char
+                       ++n;                         // nr of (multi-byte) chars
+                       p_char = mb_unescape(&p);
+                       if (p_char == NULL)
+                           p_char = p++;
+                       last = vim_iswordp(p_char);  // type of last char
                        if (same == -1 && last != first)
-                           same = n - 1;       // count of same char type
-                       p += (*mb_ptr2len)(p);
+                           same = n - 1;            // count of same char type
                    }
                    if (last && n > 2 && same >= 0 && same < n - 1)
                    {
index 29f42848d4b704c02387c75322b5249007f54df7..635193ebd34f0b6d1b883aaffd230b8c3acd2416 100644 (file)
@@ -5,11 +5,29 @@ import './util/vim9.vim' as v9
 
 func Test_abbreviation()
   new
-  " abbreviation with 0x80 should work
+
+  " abbreviation with 0x80 (full-id)
   inoreab чкпр   vim
   call feedkeys("Goчкпр \<Esc>", "xt")
   call assert_equal('vim ', getline('$'))
   iunab чкпр
+
+  " abbreviation with 0x80 (non-id)
+  inoreab abc⁀ abc^
+  inoreab ⁀ ^
+  call feedkeys("Goabc⁀ def⁀ ⁀ \<Esc>", "xt")
+  call assert_equal('abc^ def⁀ ^ ', getline('$'))
+  iunab abc⁀
+  iunab ⁀
+
+  " abbreviation with 0x9b (non-id)
+  inoreab abc; abc;
+  inoreab ; ;
+  call feedkeys("Goabc; def; ; \<Esc>", "xt")
+  call assert_equal('abc; def; ; ', getline('$'))
+  iunab abc;
+  iunab ;
+
   bwipe!
 endfunc
 
index 90ec1dc438d02ce7e6fe209b7acb58eedcedb9a8..4d961bdebd931b438a1fcb8153b3255ad5bf0dd8 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    629,
 /**/
     628,
 /**/