]> granicus.if.org Git - vim/commitdiff
patch 8.2.2933: when 'clipboard' is "unnamed" zp does not work correctly v8.2.2933
authorBram Moolenaar <Bram@vim.org>
Fri, 4 Jun 2021 15:11:47 +0000 (17:11 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 4 Jun 2021 15:11:47 +0000 (17:11 +0200)
Problem:    When 'clipboard' is "unnamed" zp and zP do not work correctly.
Solution:   Pass -1 to str_to_reg() and fix computing the character width
            instead of using the byte length. (Christian Brabandt,
            closes #8301, closes #8317)

src/clipboard.c
src/mbyte.c
src/register.c
src/version.c

index c26349291eff11da45f831e49b64b00cf591d531..b1da99bcbe4460fbe5ca1b94c5be1ab6c86aa422 100644 (file)
@@ -2090,7 +2090,7 @@ clip_yank_selection(
 
     clip_free_selection(cbd);
 
-    str_to_reg(y_ptr, type, str, len, 0L, FALSE);
+    str_to_reg(y_ptr, type, str, len, -1, FALSE);
 }
 
 /*
index 6df3a15dee42528aa6fb99bcc252fd4f3558f9fe..4b78eee0e5c10072d8f0e5e3090b696931e48c5f 100644 (file)
@@ -4308,7 +4308,6 @@ mb_charlen(char_u *str)
     return count;
 }
 
-#if (defined(FEAT_SPELL) || defined(FEAT_EVAL)) || defined(PROTO)
 /*
  * Like mb_charlen() but for a string with specified length.
  */
@@ -4323,7 +4322,6 @@ mb_charlen_len(char_u *str, int len)
 
     return count;
 }
-#endif
 
 /*
  * Try to un-escape a multi-byte character.
index f4d934393b0a1063af9703ca57112074493b99e1..8680c6bf325ec1f4d4d4c8efb3f9f950404daa82 100644 (file)
@@ -2836,6 +2836,7 @@ str_to_reg(
     char_u     **ss;
     char_u     **pp;
     long       maxlen;
+    int        charlen;
 
     if (y_ptr->y_array == NULL)                // NULL means empty register
        y_ptr->y_size = 0;
@@ -2894,22 +2895,26 @@ str_to_reg(
     {
        for (ss = (char_u **) str; *ss != NULL; ++ss, ++lnum)
        {
+           charlen = MB_CHARLEN(*ss);
            i = (long)STRLEN(*ss);
            pp[lnum] = vim_strnsave(*ss, i);
-           if (i > maxlen)
-               maxlen = i;
+           if (charlen > maxlen)
+               maxlen = charlen;
        }
     }
     else
     {
        for (start = 0; start < len + extraline; start += i + 1)
        {
+           charlen = 0;
            for (i = start; i < len; ++i)       // find the end of the line
                if (str[i] == '\n')
                    break;
            i -= start;                 // i is now length of line
-           if (i > maxlen)
-               maxlen = i;
+           if (start < len)
+               charlen = mb_charlen_len(str + start, i);
+           if (charlen > maxlen)
+               maxlen = charlen;
            if (append)
            {
                --lnum;
index 5ebcfcb07d7a12aa640a788080608b1ff8544c51..ab4ffeb39babf0cea37f367012251d1153746f92 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2933,
 /**/
     2932,
 /**/