]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0137: <Del> in cmdline mode doesn't delete composing chars v9.1.0137
authorzeertzjq <zeertzjq@outlook.com>
Mon, 26 Feb 2024 19:38:36 +0000 (20:38 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 26 Feb 2024 19:38:36 +0000 (20:38 +0100)
Problem:  <Del> in cmdline mode doesn't delete composing chars
Solution: Use mb_head_off() and mb_ptr2len() (zeertzjq)

closes: #14095

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

index 0427f0ce3c71f1b1f476629f577bb2a241e9e187..d6d81c4c71a0f44ca76ce2b04b2d17f0b134d34e 100644 (file)
@@ -4188,32 +4188,12 @@ mb_copy_char(char_u **fp, char_u **tp)
     int
 mb_off_next(char_u *base, char_u *p)
 {
-    int                i;
-    int                j;
+    int                head_off = (*mb_head_off)(base, p);
 
-    if (enc_utf8)
-    {
-       if (*p < 0x80)          // be quick for ASCII
-           return 0;
-
-       // Find the next character that isn't 10xx.xxxx
-       for (i = 0; (p[i] & 0xc0) == 0x80; ++i)
-           ;
-       if (i > 0)
-       {
-           // Check for illegal sequence.
-           for (j = 0; p - j > base; ++j)
-               if ((p[-j] & 0xc0) != 0x80)
-                   break;
-           if (utf8len_tab[p[-j]] != i + j)
-               return 0;
-       }
-       return i;
-    }
+    if (head_off == 0)
+       return 0;
 
-    // Only need to check if we're on a trail byte, it doesn't matter if we
-    // want the offset to the next or current character.
-    return (*mb_head_off)(base, p);
+    return (*mb_ptr2len)(p - head_off) - head_off;
 }
 
 /*
index c0d01fb967bfbdde2b94277dfe746957cd21be2f..7c86bcd123e562918cdb8e44e2fadd26a025e512 100644 (file)
@@ -917,6 +917,26 @@ func Test_cmdline_remove_char()
   let &encoding = encoding_save
 endfunc
 
+func Test_cmdline_del_utf8()
+  let @s = '⒌'
+  call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx')
+  call assert_equal('",,', @:)
+
+  let @s = 'a̳'
+  call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx')
+  call assert_equal('",,', @:)
+
+  let @s = 'β̳'
+  call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx')
+  call assert_equal('",,', @:)
+
+  if has('arabic')
+    let @s = 'لا'
+    call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx')
+    call assert_equal('",,', @:)
+  endif
+endfunc
+
 func Test_cmdline_keymap_ctrl_hat()
   CheckFeature keymap
 
index 6d6a5a19a84ddb15bb9d0675c2fa2df88ecc7874..38201599efb373ac7b73551998dd2456555755f5 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    137,
 /**/
     136,
 /**/