]> granicus.if.org Git - vim/commitdiff
patch 8.2.4988: textprop in wrong position when replacing multi-byte chars v8.2.4988
authorLemonBoy <thatlemon@gmail.com>
Sat, 21 May 2022 10:20:42 +0000 (11:20 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 21 May 2022 10:20:42 +0000 (11:20 +0100)
Problem:    Textprop in wrong position when replacing multi-byte chars.
Solution:   Adjust textprop position. (closes #10461)

src/change.c
src/testdir/test_textprop.vim
src/version.c

index 47411ca59bea77b52e1ee3a58a59e02355a7fea1..2d01f92586b7d229254c438023a6a00f15f617a5 100644 (file)
@@ -1118,7 +1118,12 @@ ins_char_bytes(char_u *buf, int charlen)
     ml_replace(lnum, newp, FALSE);
 
     // mark the buffer as changed and prepare for displaying
-    inserted_bytes(lnum, col, newlen - oldlen);
+    changed_bytes(lnum, col);
+#ifdef FEAT_PROP_POPUP
+    if (curbuf->b_has_textprop && newlen != oldlen)
+       adjust_prop_columns(lnum, col, newlen - oldlen,
+                                   State & REPLACE_FLAG ? APC_SUBSTITUTE : 0);
+#endif
 
     // If we're in Insert or Replace mode and 'showmatch' is set, then briefly
     // show the match for right parens and braces.
index 3203305e8c0174bed6231f27df92678879f607c9..c29c10b27fb34e5da965729e9e9f4f0532cd19c9 100644 (file)
@@ -573,6 +573,13 @@ func Test_prop_replace()
   call assert_equal('yyyex xyyoxx', getline(1))
   call assert_equal(expected, prop_list(1))
 
+  " Replace three 1-byte chars with three 2-byte ones.
+  exe "normal 0l3rø"
+  call assert_equal('yøøøx xyyoxx', getline(1))
+  let expected[0].length += 3
+  let expected[1].col += 3
+  call assert_equal(expected, prop_list(1))
+
   call DeletePropTypes()
   bwipe!
   set bs&
index 708f4a8ed3d43f1f0a978ea62e645c3ffa954cc8..ec25334d3f0fe875fb22e573d257bab9a83ee739 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4988,
 /**/
     4987,
 /**/