Patch 8.1.0665
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.
Files: src/screen.c, src/testdir/test_textprop.vim,
src/testdir/dumps/Test_textprop_01.dump
*** ../vim-8.1.0664/src/screen.c 2018-12-30 22:07:35.596868093 +0100
--- src/screen.c 2018-12-31 13:38:32.001788595 +0100
***************
*** 3051,3056 ****
--- 3051,3088 ----
}
#endif /* FEAT_FOLDING */
+ #ifdef FEAT_TEXT_PROP
+ static textprop_T *current_text_props = NULL;
+ static buf_T *current_buf = NULL;
+
+ static int
+ #ifdef __BORLANDC__
+ _RTLENTRYF
+ #endif
+ text_prop_compare(const void *s1, const void *s2)
+ {
+ int idx1, idx2;
+ proptype_T *pt1, *pt2;
+ colnr_T col1, col2;
+
+ idx1 = *(int *)s1;
+ idx2 = *(int *)s2;
+ pt1 = text_prop_type_by_id(current_buf, current_text_props[idx1].tp_type);
+ pt2 = text_prop_type_by_id(current_buf, current_text_props[idx2].tp_type);
+ if (pt1 == pt2)
+ return 0;
+ if (pt1 == NULL)
+ return -1;
+ if (pt2 == NULL)
+ return 1;
+ if (pt1->pt_priority != pt2->pt_priority)
+ return pt1->pt_priority > pt2->pt_priority ? 1 : -1;
+ col1 = current_text_props[idx1].tp_col;
+ col2 = current_text_props[idx2].tp_col;
+ return col1 == col2 ? 0 : col1 > col2 ? 1 : -1;
+ }
+ #endif
+
/*
* Display line "lnum" of window 'wp' on the screen.
* Start at row "startrow", stop when "endrow" is reached.
***************
*** 4322,4355 ****
&& vcol >= text_props[text_prop_next].tp_col - 1)
text_prop_idxs[text_props_active++] = text_prop_next++;
! text_prop_type = NULL;
if (text_props_active > 0)
{
! int max_priority = INT_MIN;
! int max_col = 0;
- // Get the property type with the highest priority
- // and/or starting last.
for (pi = 0; pi < text_props_active; ++pi)
{
! int tpi = text_prop_idxs[pi];
! proptype_T *pt;
! pt = text_prop_type_by_id(
! curwin->w_buffer, text_props[tpi].tp_type);
! if (pt != NULL
! && (pt->pt_priority > max_priority
! || (pt->pt_priority == max_priority
! && text_props[tpi].tp_col >= max_col)))
{
text_prop_type = pt;
! max_priority = pt->pt_priority;
! max_col = text_props[tpi].tp_col;
}
}
- if (text_prop_type != NULL)
- text_prop_attr =
- syn_id2attr(text_prop_type->pt_hl_id);
}
}
#endif
--- 4354,4385 ----
&& vcol >= text_props[text_prop_next].tp_col - 1)
text_prop_idxs[text_props_active++] = text_prop_next++;
! text_prop_attr = 0;
if (text_props_active > 0)
{
! // Sort the properties on priority and/or starting last.
! // Then combine the attributes, highest priority last.
! current_text_props = text_props;
! current_buf = wp->w_buffer;
! qsort((void *)text_prop_idxs, (size_t)text_props_active,
! sizeof(int), text_prop_compare);
for (pi = 0; pi < text_props_active; ++pi)
{
! int tpi = text_prop_idxs[pi];
! proptype_T *pt = text_prop_type_by_id(wp->w_buffer,
text_props[tpi].tp_type);
! if (pt != NULL)
{
+ int pt_attr = syn_id2attr(pt->pt_hl_id);
+
text_prop_type = pt;
! if (text_prop_attr == 0)
! text_prop_attr = pt_attr;
! else
! text_prop_attr =
hl_combine_attr(text_prop_attr, pt_attr);
}
}
}
}
#endif
***************
*** 4775,4784 ****
if (has_spell && v >= word_end && v > cur_checked_col)
{
spell_attr = 0;
- # ifdef FEAT_SYN_HL
- if (!attr_pri)
- char_attr = syntax_attr;
- # endif
if (c != 0 && (
# ifdef FEAT_SYN_HL
!has_syntax ||
--- 4805,4810 ----
*** ../vim-8.1.0664/src/testdir/test_textprop.vim 2018-12-28
23:22:36.270750732 +0100
--- src/testdir/test_textprop.vim 2018-12-31 12:41:37.979473855 +0100
***************
*** 5,10 ****
--- 5,12 ----
finish
endif
+ source screendump.vim
+
func Test_proptype_global()
call prop_type_add('comment', {'highlight': 'Directory', 'priority': 123,
'start_incl': 1, 'end_incl': 1})
let proptypes = prop_type_list()
***************
*** 283,287 ****
call prop_type_delete('comment')
endfunc
!
! " TODO: screenshot test with highlighting
--- 285,311 ----
call prop_type_delete('comment')
endfunc
! " screenshot test with textprop highlighting
! funct Test_textprop_screenshots()
! if !CanRunVimInTerminal()
! return
! endif
! call writefile([
! \ "call setline(1, ['One two', 'Number 123 and then 4567.', 'Three'])",
! \ "hi NumberProp ctermfg=blue",
! \ "hi LongProp ctermbg=yellow",
! \ "call prop_type_add('number', {'highlight': 'NumberProp'})",
! \ "call prop_type_add('long', {'highlight': 'LongProp'})",
! \ "call prop_add(1, 4, {'end_lnum': 3, 'end_col': 3, 'type': 'long'})",
! \ "call prop_add(2, 8, {'length': 3, 'type': 'number'})",
! \ "call prop_add(2, 21, {'length': 4, 'type': 'number'})",
! \ "set number",
! \ "set spell",
! \], 'XtestProp')
! let buf = RunVimInTerminal('-S XtestProp', {})
! call VerifyScreenDump(buf, 'Test_textprop_01', {})
!
! " clean up
! call StopVimInTerminal(buf)
! call delete('Xtest_folds_with_rnu')
! endfunc
*** ../vim-8.1.0664/src/testdir/dumps/Test_textprop_01.dump 2018-12-31
13:54:54.313537883 +0100
--- src/testdir/dumps/Test_textprop_01.dump 2018-12-31 12:43:50.366431472
+0100
***************
*** 0 ****
--- 1,20 ----
+ | +0#af5f00255#ffffff0@1|1| >O+0#0000000&|n|e| +0&#ffff4012|t|w|o|
+0&#ffffff0@63
+ | +0#af5f00255&@1|2| |N+0#0000000#ffff4012|u|m|b|e|r|
|1+0#4040ff13#ffffff0|2|3| +0#0000000#ffff4012|a|n|d| |t|h|e|n|
|4+0#4040ff13#ffffff0|5|6|7|.+0#0000000#ffff4012| +0&#ffffff0@45
+ | +0#af5f00255&@1|3| |T+0#0000000#ffff4012|h|r|e+0&#ffffff0@1| @65
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ | +0#0000000&@56|1|,|1| @10|A|l@1|
*** ../vim-8.1.0664/src/version.c 2018-12-30 22:55:43.671136682 +0100
--- src/version.c 2018-12-31 12:16:31.671760142 +0100
***************
*** 801,802 ****
--- 801,804 ----
{ /* Add new patch number below this line */
+ /**/
+ 665,
/**/
--
hundred-and-one symptoms of being an internet addict:
91. It's Saturday afternoon in the middle of May and you
are on computer.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.