]> granicus.if.org Git - vim/commitdiff
patch 8.2.2935: calculating register width is not always needed v8.2.2935
authorBram Moolenaar <Bram@vim.org>
Fri, 4 Jun 2021 17:17:07 +0000 (19:17 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 4 Jun 2021 17:17:07 +0000 (19:17 +0200)
Problem:    Calculating register width is not always needed. (Christian
            Brabandt)
Solution:   Only calculate the width when the type is MBLOCK.

src/register.c
src/version.c

index 8c951b7eabab9b8c6c903ec34a84faba6f1869cb..5dc8f2896a4894a3fe9caefbe15e2d284240a8b4 100644 (file)
@@ -2836,7 +2836,6 @@ 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;
@@ -2895,23 +2894,28 @@ 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 (charlen > maxlen)
-               maxlen = charlen;
+           pp[lnum] = vim_strsave(*ss);
+           if (type == MBLOCK)
+           {
+               int charlen = mb_string2cells(*ss, -1);
+
+               if (charlen > maxlen)
+                   maxlen = charlen;
+           }
        }
     }
     else
     {
        for (start = 0; start < len + extraline; start += i + 1)
        {
-           charlen = 0;
+           int charlen = 0;
+
            for (i = start; i < len; ++i)       // find the end of the line
            {
                if (str[i] == '\n')
                    break;
-               charlen += mb_ptr2cells_len(str + i, len - i);
+               if (type == MBLOCK)
+                   charlen += mb_ptr2cells_len(str + i, len - i);
            }
            i -= start;                 // i is now length of line
            if (charlen > maxlen)
index eab59f42efbf14fc7b2f42d25acf6eb76da7e57c..d55bb30ce31ef9c297c47c698f07a78bb106d8a4 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2935,
 /**/
     2934,
 /**/