]> granicus.if.org Git - vim/commitdiff
Fix: Composing characters in :s substitute text were dropped.
authorBram Moolenaar <Bram@vim.org>
Mon, 12 Jul 2010 20:42:33 +0000 (22:42 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 12 Jul 2010 20:42:33 +0000 (22:42 +0200)
src/regexp.c

index ae1b03a111ba64114dfae6069d785140917b5b00..480f4cc690db209e96edc34ed7f2d561063d4d2f 100644 (file)
@@ -7140,10 +7140,26 @@ vim_regsub_both(source, dest, copy, magic, backslash)
 #ifdef FEAT_MBYTE
            if (has_mbyte)
            {
-               src += mb_ptr2len(src - 1) - 1;
+               int totlen = mb_ptr2len(src - 1);
+
                if (copy)
                    mb_char2bytes(cc, dst);
                dst += mb_char2len(cc) - 1;
+               if (enc_utf8)
+               {
+                   int clen = utf_ptr2len(src - 1);
+
+                   /* If the character length is shorter than "totlen", there
+                    * are composing characters; copy them as-is. */
+                   if (clen < totlen)
+                   {
+                       if (copy)
+                           mch_memmove(dst + 1, src - 1 + clen,
+                                                    (size_t)(totlen - clen));
+                       dst += totlen - clen;
+                   }
+               }
+               src += totlen - 1;
            }
            else
 #endif