patch 8.1.2279: computation of highlight attributes is too complicated
Problem: Computation of highlight attributes is too complicated.
Solution: Simplify the attribute computation and make it more consistent.
(closes #5190) Fix that 'combine' set to zero doesn't work.
diff --git a/src/drawline.c b/src/drawline.c
index ea9e4a9..5cfec84 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -1470,6 +1470,16 @@
# endif
}
}
+# ifdef FEAT_TEXT_PROP
+ // Combine text property highlight into syntax highlight.
+ if (text_prop_type != NULL)
+ {
+ if (text_prop_combine)
+ syntax_attr = hl_combine_attr(syntax_attr, text_prop_attr);
+ else
+ syntax_attr = text_prop_attr;
+ }
+# endif
#endif
// Decide which of the highlight attributes to use.
@@ -1479,28 +1489,16 @@
{
char_attr = hl_combine_attr(line_attr, area_attr);
# ifdef FEAT_SYN_HL
- if (syntax_attr != 0)
- char_attr = hl_combine_attr(syntax_attr, char_attr);
+ char_attr = hl_combine_attr(syntax_attr, char_attr);
# endif
}
else if (search_attr != 0)
{
char_attr = hl_combine_attr(line_attr, search_attr);
# ifdef FEAT_SYN_HL
- if (syntax_attr != 0)
- char_attr = hl_combine_attr(syntax_attr, char_attr);
+ char_attr = hl_combine_attr(syntax_attr, char_attr);
# endif
}
-# ifdef FEAT_TEXT_PROP
- else if (text_prop_type != NULL)
- {
- char_attr = hl_combine_attr(line_attr != 0
- ? line_attr
- : syntax_attr != 0
- ? syntax_attr
- : win_attr, text_prop_attr);
- }
-# endif
else if (line_attr != 0 && ((fromcol == -10 && tocol == MAXCOL)
|| vcol < fromcol || vcol_prev < fromcol_prev
|| vcol >= tocol))
@@ -1508,11 +1506,10 @@
// Use line_attr when not in the Visual or 'incsearch' area
// (area_attr may be 0 when "noinvcur" is set).
# ifdef FEAT_SYN_HL
- if (syntax_attr != 0)
- char_attr = hl_combine_attr(syntax_attr, line_attr);
- else
+ char_attr = hl_combine_attr(syntax_attr, line_attr);
+# else
+ char_attr = line_attr;
# endif
- char_attr = line_attr;
attr_pri = FALSE;
}
#else
@@ -1524,22 +1521,10 @@
else
{
attr_pri = FALSE;
-#ifdef FEAT_TEXT_PROP
- if (text_prop_type != NULL)
- {
- if (text_prop_combine)
- char_attr = hl_combine_attr(
- syntax_attr, text_prop_attr);
- else
- char_attr = hl_combine_attr(
- win_attr, text_prop_attr);
- }
- else
-#endif
#ifdef FEAT_SYN_HL
- char_attr = syntax_attr;
+ char_attr = syntax_attr;
#else
- char_attr = 0;
+ char_attr = 0;
#endif
}
}