From: zeertzjq Date: Sat, 13 Jun 2026 15:59:45 +0000 (+0000) Subject: patch 9.2.0629: 0x80 and 0x9b byte not unescaped when check for valid abbr X-Git-Tag: v9.2.0629^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1958c991a8663749f2a56009cc65694d292a2a87;p=thirdparty%2Fvim.git patch 9.2.0629: 0x80 and 0x9b byte not unescaped when check for valid abbr 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 Signed-off-by: Christian Brabandt --- diff --git a/src/map.c b/src/map.c index 34e465ec3f..50d7ee4bcb 100644 --- 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) { diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim index 29f42848d4..635193ebd3 100644 --- a/src/testdir/test_mapping.vim +++ b/src/testdir/test_mapping.vim @@ -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чкпр \", "xt") call assert_equal('vim ', getline('$')) iunab чкпр + + " abbreviation with 0x80 (non-id) + inoreab abc⁀ abc^ + inoreab ⁀ ^ + call feedkeys("Goabc⁀ def⁀ ⁀ \", "xt") + call assert_equal('abc^ def⁀ ^ ', getline('$')) + iunab abc⁀ + iunab ⁀ + + " abbreviation with 0x9b (non-id) + inoreab abc; abc; + inoreab ; ; + call feedkeys("Goabc; def; ; \", "xt") + call assert_equal('abc; def; ; ', getline('$')) + iunab abc; + iunab ; + bwipe! endfunc diff --git a/src/version.c b/src/version.c index 90ec1dc438..4d961bdebd 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 629, /**/ 628, /**/