# HG changeset patch # User Bram Moolenaar # Date 1659906003 -7200 # Node ID 23dceecc0bf88ff34a3913b7eda4405c685d0d4a # Parent e5f6f17e01709704511cb4362cf5d890008dc698 patch 9.0.0166: when using text properties line text length computed twice Commit: https://github.com/vim/vim/commit/50652b0c5cfc9d48d3561772420e1f01f878f033 Author: Bram Moolenaar Date: Sun Aug 7 21:48:37 2022 +0100 patch 9.0.0166: when using text properties line text length computed twice 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. diff --git a/src/memline.c b/src/memline.c --- a/src/memline.c +++ b/src/memline.c @@ -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 + // The line was inserted below 'lnum' + ml_updatechunk(buf, lnum + 1, # 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); + (long)text_len +# else + (long)len +#endif + , ML_CHNK_ADDLINE); #endif #ifdef FEAT_NETBEANS_INTG diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -736,6 +736,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 166, +/**/ 165, /**/ 164,