]> granicus.if.org Git - vim/commitdiff
patch 9.0.0166: when using text properties line text length computed twice v9.0.0166
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Aug 2022 20:48:37 +0000 (21:48 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Aug 2022 20:48:37 +0000 (21:48 +0100)
Problem:    When using text properties the line text length is computed twice.
Solution:   If the text lenght was already computed don't do it again.

src/memline.c
src/version.c

index 2f73477b5f7fb94f0248601b5540c87ba8bffd71..0b1815a37d139d40f2673ee50a14e8cfa535c662 100644 (file)
@@ -2821,6 +2821,9 @@ ml_append_int(
     infoptr_T  *ip;
 #ifdef FEAT_PROP_POPUP
     char_u     *tofree = NULL;
+# ifdef FEAT_BYTEOFF
+    colnr_T    text_len = 0;   // text len with NUL without text properties
+# endif
 #endif
     int                ret = FAIL;
 
@@ -2831,7 +2834,19 @@ ml_append_int(
        lowest_marked = lnum + 1;
 
     if (len == 0)
+    {
        len = (colnr_T)STRLEN(line) + 1;        // space needed for the text
+#if defined(FEAT_PROP_POPUP) && defined(FEAT_BYTEOFF)
+       text_len = len;
+#endif
+    }
+#if defined(FEAT_PROP_POPUP) && defined(FEAT_BYTEOFF)
+    else if (curbuf->b_has_textprop)
+       // "len" may include text properties, get the length of the text.
+       text_len = (colnr_T)STRLEN(line) + 1;
+    else
+       text_len = len;
+#endif
 
 #ifdef FEAT_PROP_POPUP
     if (curbuf->b_has_textprop && lnum > 0
@@ -3292,13 +3307,14 @@ ml_append_int(
     }
 
 #ifdef FEAT_BYTEOFF
-# ifdef FEAT_PROP_POPUP
-    if (curbuf->b_has_textprop)
-       // only use the space needed for the text, ignore properties
-       len = (colnr_T)STRLEN(line) + 1;
-# endif
     // The line was inserted below 'lnum'
-    ml_updatechunk(buf, lnum + 1, (long)len, ML_CHNK_ADDLINE);
+    ml_updatechunk(buf, lnum + 1,
+# ifdef FEAT_PROP_POPUP
+           (long)text_len
+# else
+           (long)len
+#endif
+           , ML_CHNK_ADDLINE);
 #endif
 
 #ifdef FEAT_NETBEANS_INTG
index bccf787ef800f8dd7981e8de974b57fe0691564f..7544d6f1a91c43c8d40a7ba733b0a4ca54c5153e 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    166,
 /**/
     165,
 /**/