comparison src/memline.c @ 29651:23dceecc0bf8 v9.0.0166

patch 9.0.0166: when using text properties line text length computed twice Commit: https://github.com/vim/vim/commit/50652b0c5cfc9d48d3561772420e1f01f878f033 Author: Bram Moolenaar <Bram@vim.org> 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.
author Bram Moolenaar <Bram@vim.org>
date Sun, 07 Aug 2022 23:00:03 +0200
parents fba9e366ced4
children 57cfb39b7842
comparison
equal deleted inserted replaced
29650:e5f6f17e0170 29651:23dceecc0bf8
2819 DATA_BL *dp; 2819 DATA_BL *dp;
2820 PTR_BL *pp; 2820 PTR_BL *pp;
2821 infoptr_T *ip; 2821 infoptr_T *ip;
2822 #ifdef FEAT_PROP_POPUP 2822 #ifdef FEAT_PROP_POPUP
2823 char_u *tofree = NULL; 2823 char_u *tofree = NULL;
2824 # ifdef FEAT_BYTEOFF
2825 colnr_T text_len = 0; // text len with NUL without text properties
2826 # endif
2824 #endif 2827 #endif
2825 int ret = FAIL; 2828 int ret = FAIL;
2826 2829
2827 if (lnum > buf->b_ml.ml_line_count || buf->b_ml.ml_mfp == NULL) 2830 if (lnum > buf->b_ml.ml_line_count || buf->b_ml.ml_mfp == NULL)
2828 return FAIL; // lnum out of range 2831 return FAIL; // lnum out of range
2829 2832
2830 if (lowest_marked && lowest_marked > lnum) 2833 if (lowest_marked && lowest_marked > lnum)
2831 lowest_marked = lnum + 1; 2834 lowest_marked = lnum + 1;
2832 2835
2833 if (len == 0) 2836 if (len == 0)
2837 {
2834 len = (colnr_T)STRLEN(line) + 1; // space needed for the text 2838 len = (colnr_T)STRLEN(line) + 1; // space needed for the text
2839 #if defined(FEAT_PROP_POPUP) && defined(FEAT_BYTEOFF)
2840 text_len = len;
2841 #endif
2842 }
2843 #if defined(FEAT_PROP_POPUP) && defined(FEAT_BYTEOFF)
2844 else if (curbuf->b_has_textprop)
2845 // "len" may include text properties, get the length of the text.
2846 text_len = (colnr_T)STRLEN(line) + 1;
2847 else
2848 text_len = len;
2849 #endif
2835 2850
2836 #ifdef FEAT_PROP_POPUP 2851 #ifdef FEAT_PROP_POPUP
2837 if (curbuf->b_has_textprop && lnum > 0 2852 if (curbuf->b_has_textprop && lnum > 0
2838 && !(flags & (ML_APPEND_UNDO | ML_APPEND_NOPROP))) 2853 && !(flags & (ML_APPEND_UNDO | ML_APPEND_NOPROP)))
2839 // Add text properties that continue from the previous line. 2854 // Add text properties that continue from the previous line.
3290 buf->b_ml.ml_stack_top = 0; // invalidate stack 3305 buf->b_ml.ml_stack_top = 0; // invalidate stack
3291 } 3306 }
3292 } 3307 }
3293 3308
3294 #ifdef FEAT_BYTEOFF 3309 #ifdef FEAT_BYTEOFF
3310 // The line was inserted below 'lnum'
3311 ml_updatechunk(buf, lnum + 1,
3295 # ifdef FEAT_PROP_POPUP 3312 # ifdef FEAT_PROP_POPUP
3296 if (curbuf->b_has_textprop) 3313 (long)text_len
3297 // only use the space needed for the text, ignore properties 3314 # else
3298 len = (colnr_T)STRLEN(line) + 1; 3315 (long)len
3299 # endif 3316 #endif
3300 // The line was inserted below 'lnum' 3317 , ML_CHNK_ADDLINE);
3301 ml_updatechunk(buf, lnum + 1, (long)len, ML_CHNK_ADDLINE);
3302 #endif 3318 #endif
3303 3319
3304 #ifdef FEAT_NETBEANS_INTG 3320 #ifdef FEAT_NETBEANS_INTG
3305 if (netbeans_active()) 3321 if (netbeans_active())
3306 { 3322 {