patch 9.1.0132: "C" doesn't include composing chars with 'virtualedit'

Commit: 
https://github.com/vim/vim/commit/048761bcd40ec630fd3e039f0066cf4e484ceabd
Author: zeertzjq <zeert...@outlook.com>
Date:   Sat Feb 24 14:21:39 2024 +0100

    patch 9.1.0132: "C" doesn't include composing chars with 'virtualedit'
    
    Problem:  using "C" and 've=all' set, doesn't include composing chars
              when changing a line, keeps the composing chars for whatever
              is typed afterwards.
    Solution: Use mb_head_off() and mb_ptr2len() instead of mb_tail_off().
              (zeertzjq)
    
    closes: #14083
    
    Signed-off-by: zeertzjq <zeert...@outlook.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/ops.c b/src/ops.c
index e66b4b5ee..57e699150 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -990,13 +990,20 @@ setmarks:
     static void
 mb_adjust_opend(oparg_T *oap)
 {
-    char_u     *p;
+    char_u     *line;
+    char_u     *ptr;
 
     if (!oap->inclusive)
        return;
 
-    p = ml_get(oap->end.lnum);
-    oap->end.col += mb_tail_off(p, p + oap->end.col);
+    line = ml_get(oap->end.lnum);
+    ptr = line + oap->end.col;
+    if (*ptr != NUL)
+    {
+       ptr -= (*mb_head_off)(line, ptr);
+       ptr += (*mb_ptr2len)(ptr) - 1;
+       oap->end.col = ptr - line;
+    }
 }
 
 /*
diff --git a/src/testdir/test_virtualedit.vim b/src/testdir/test_virtualedit.vim
index ec2b276c3..48d4aa061 100644
--- a/src/testdir/test_virtualedit.vim
+++ b/src/testdir/test_virtualedit.vim
@@ -77,13 +77,30 @@ endfunc
 func Test_edit_change()
   new
   set virtualedit=all
+
   call setline(1, "    ⒌")
   normal Cx
   call assert_equal('x', getline(1))
+
+  call setline(1, "    a̳")
+  normal Cx
+  call assert_equal('x', getline(1))
+
+  call setline(1, "    β̳")
+  normal Cx
+  call assert_equal('x', getline(1))
+
+  if has('arabic')
+    call setline(1, "  لا")
+    normal Cx
+    call assert_equal('x', getline(1))
+  endif
+
   " Do a visual block change
   call setline(1, ['a', 'b', 'c'])
   exe "normal gg3l\<C-V>2jcx"
   call assert_equal(['a  x', 'b  x', 'c  x'], getline(1, '$'))
+
   bwipe!
   set virtualedit=
 endfunc
diff --git a/src/version.c b/src/version.c
index a80f2a87b..59a940ba0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    132,
 /**/
     131,
 /**/

-- 
-- 
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/E1rds6O-00GPP6-Hv%40256bit.org.

Reply via email to