comparison src/screen.c @ 15314:c4d62945d96f v8.1.0665

patch 8.1.0665: text property display wrong when 'spell' is set commit https://github.com/vim/vim/commit/c6d86dccc4edff8627e309fb23dc8f810ef36b28 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 31 13:57:36 2018 +0100 patch 8.1.0665: text property display wrong when 'spell' is set Problem: Text property display wrong when 'spell' is set. (Dominique Pelle) Solution: Remove unnecessary assignment to char_attr. Combine attributes if needed. Add a screenshot test.
author Bram Moolenaar <Bram@vim.org>
date Mon, 31 Dec 2018 14:00:06 +0100
parents 34a04c9a3575
children 0eed23d9733a
comparison
equal deleted inserted replaced
15313:cecacba2a0d8 15314:c4d62945d96f
3049 if (closed) 3049 if (closed)
3050 p[i >= fdc ? i - 1 : i] = '+'; 3050 p[i >= fdc ? i - 1 : i] = '+';
3051 } 3051 }
3052 #endif /* FEAT_FOLDING */ 3052 #endif /* FEAT_FOLDING */
3053 3053
3054 #ifdef FEAT_TEXT_PROP
3055 static textprop_T *current_text_props = NULL;
3056 static buf_T *current_buf = NULL;
3057
3058 static int
3059 #ifdef __BORLANDC__
3060 _RTLENTRYF
3061 #endif
3062 text_prop_compare(const void *s1, const void *s2)
3063 {
3064 int idx1, idx2;
3065 proptype_T *pt1, *pt2;
3066 colnr_T col1, col2;
3067
3068 idx1 = *(int *)s1;
3069 idx2 = *(int *)s2;
3070 pt1 = text_prop_type_by_id(current_buf, current_text_props[idx1].tp_type);
3071 pt2 = text_prop_type_by_id(current_buf, current_text_props[idx2].tp_type);
3072 if (pt1 == pt2)
3073 return 0;
3074 if (pt1 == NULL)
3075 return -1;
3076 if (pt2 == NULL)
3077 return 1;
3078 if (pt1->pt_priority != pt2->pt_priority)
3079 return pt1->pt_priority > pt2->pt_priority ? 1 : -1;
3080 col1 = current_text_props[idx1].tp_col;
3081 col2 = current_text_props[idx2].tp_col;
3082 return col1 == col2 ? 0 : col1 > col2 ? 1 : -1;
3083 }
3084 #endif
3085
3054 /* 3086 /*
3055 * Display line "lnum" of window 'wp' on the screen. 3087 * Display line "lnum" of window 'wp' on the screen.
3056 * Start at row "startrow", stop when "endrow" is reached. 3088 * Start at row "startrow", stop when "endrow" is reached.
3057 * wp->w_virtcol needs to be valid. 3089 * wp->w_virtcol needs to be valid.
3058 * 3090 *
4320 // Add any text property that starts in this column. 4352 // Add any text property that starts in this column.
4321 while (text_prop_next < text_prop_count 4353 while (text_prop_next < text_prop_count
4322 && vcol >= text_props[text_prop_next].tp_col - 1) 4354 && vcol >= text_props[text_prop_next].tp_col - 1)
4323 text_prop_idxs[text_props_active++] = text_prop_next++; 4355 text_prop_idxs[text_props_active++] = text_prop_next++;
4324 4356
4325 text_prop_type = NULL; 4357 text_prop_attr = 0;
4326 if (text_props_active > 0) 4358 if (text_props_active > 0)
4327 { 4359 {
4328 int max_priority = INT_MIN; 4360 // Sort the properties on priority and/or starting last.
4329 int max_col = 0; 4361 // Then combine the attributes, highest priority last.
4330 4362 current_text_props = text_props;
4331 // Get the property type with the highest priority 4363 current_buf = wp->w_buffer;
4332 // and/or starting last. 4364 qsort((void *)text_prop_idxs, (size_t)text_props_active,
4365 sizeof(int), text_prop_compare);
4366
4333 for (pi = 0; pi < text_props_active; ++pi) 4367 for (pi = 0; pi < text_props_active; ++pi)
4334 { 4368 {
4335 int tpi = text_prop_idxs[pi]; 4369 int tpi = text_prop_idxs[pi];
4336 proptype_T *pt; 4370 proptype_T *pt = text_prop_type_by_id(wp->w_buffer, text_props[tpi].tp_type);
4337 4371
4338 pt = text_prop_type_by_id( 4372 if (pt != NULL)
4339 curwin->w_buffer, text_props[tpi].tp_type);
4340 if (pt != NULL
4341 && (pt->pt_priority > max_priority
4342 || (pt->pt_priority == max_priority
4343 && text_props[tpi].tp_col >= max_col)))
4344 { 4373 {
4374 int pt_attr = syn_id2attr(pt->pt_hl_id);
4375
4345 text_prop_type = pt; 4376 text_prop_type = pt;
4346 max_priority = pt->pt_priority; 4377 if (text_prop_attr == 0)
4347 max_col = text_props[tpi].tp_col; 4378 text_prop_attr = pt_attr;
4379 else
4380 text_prop_attr = hl_combine_attr(text_prop_attr, pt_attr);
4348 } 4381 }
4349 } 4382 }
4350 if (text_prop_type != NULL)
4351 text_prop_attr =
4352 syn_id2attr(text_prop_type->pt_hl_id);
4353 } 4383 }
4354 } 4384 }
4355 #endif 4385 #endif
4356 4386
4357 /* Decide which of the highlight attributes to use. */ 4387 /* Decide which of the highlight attributes to use. */
4773 * @Spell cluster is not used or the current syntax item 4803 * @Spell cluster is not used or the current syntax item
4774 * contains the @Spell cluster. */ 4804 * contains the @Spell cluster. */
4775 if (has_spell && v >= word_end && v > cur_checked_col) 4805 if (has_spell && v >= word_end && v > cur_checked_col)
4776 { 4806 {
4777 spell_attr = 0; 4807 spell_attr = 0;
4778 # ifdef FEAT_SYN_HL
4779 if (!attr_pri)
4780 char_attr = syntax_attr;
4781 # endif
4782 if (c != 0 && ( 4808 if (c != 0 && (
4783 # ifdef FEAT_SYN_HL 4809 # ifdef FEAT_SYN_HL
4784 !has_syntax || 4810 !has_syntax ||
4785 # endif 4811 # endif
4786 can_spell)) 4812 can_spell))