mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
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.
This commit is contained in:
70
src/screen.c
70
src/screen.c
@@ -3051,6 +3051,38 @@ fill_foldcolumn(
|
||||
}
|
||||
#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,34 +4354,32 @@ win_line(
|
||||
&& vcol >= text_props[text_prop_next].tp_col - 1)
|
||||
text_prop_idxs[text_props_active++] = text_prop_next++;
|
||||
|
||||
text_prop_type = NULL;
|
||||
text_prop_attr = 0;
|
||||
if (text_props_active > 0)
|
||||
{
|
||||
int max_priority = INT_MIN;
|
||||
int max_col = 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);
|
||||
|
||||
// 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;
|
||||
int tpi = text_prop_idxs[pi];
|
||||
proptype_T *pt = text_prop_type_by_id(wp->w_buffer, text_props[tpi].tp_type);
|
||||
|
||||
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)))
|
||||
if (pt != NULL)
|
||||
{
|
||||
int pt_attr = syn_id2attr(pt->pt_hl_id);
|
||||
|
||||
text_prop_type = pt;
|
||||
max_priority = pt->pt_priority;
|
||||
max_col = text_props[tpi].tp_col;
|
||||
if (text_prop_attr == 0)
|
||||
text_prop_attr = pt_attr;
|
||||
else
|
||||
text_prop_attr = hl_combine_attr(text_prop_attr, pt_attr);
|
||||
}
|
||||
}
|
||||
if (text_prop_type != NULL)
|
||||
text_prop_attr =
|
||||
syn_id2attr(text_prop_type->pt_hl_id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -4775,10 +4805,6 @@ win_line(
|
||||
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 ||
|
||||
|
20
src/testdir/dumps/Test_textprop_01.dump
Normal file
20
src/testdir/dumps/Test_textprop_01.dump
Normal file
@@ -0,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|
|
@@ -5,6 +5,8 @@ if !has('textprop')
|
||||
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,5 +285,27 @@ func Test_prop_byteoff()
|
||||
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', {})
|
||||
|
||||
" TODO: screenshot test with highlighting
|
||||
" clean up
|
||||
call StopVimInTerminal(buf)
|
||||
call delete('Xtest_folds_with_rnu')
|
||||
endfunc
|
||||
|
@@ -799,6 +799,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
665,
|
||||
/**/
|
||||
664,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user