mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 10:56:31 +00:00
fix(drawline): combine extmark highligh with area hl correctly
fixes #23734 Get rid of the weird attr_pri dance which always seemed like a kludge: if (!attr_pri) { wlv.char_attr = hl_combine_attr(wlv.char_attr, extmark_attr); } else { wlv.char_attr = hl_combine_attr(extmark_attr, wlv.char_attr); } Instead combine extmark attrs with (old-skool) syntax attrs in a consistent way and then combine that with attr_pri and the rest in an _unified_ code path fixes #23722 Co-authored-by: luukvbaal <luukvbaal@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
@@ -1073,7 +1073,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
int saved_search_attr = 0; // search_attr to be used when n_extra
|
||||
// goes to zero
|
||||
int vcol_save_attr = 0; // saved attr for 'cursorcolumn'
|
||||
int syntax_attr = 0; // attributes desired by syntax
|
||||
int decor_attr = 0; // attributes desired by syntax and extmarks
|
||||
bool has_syntax = false; // this buffer has syntax highl.
|
||||
int save_did_emsg;
|
||||
int eol_hl_off = 0; // 1 if highlighted char after EOL
|
||||
@@ -1902,11 +1902,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
wlv.char_attr = wlv.line_attr;
|
||||
} else {
|
||||
attr_pri = false;
|
||||
if (has_syntax) {
|
||||
wlv.char_attr = syntax_attr;
|
||||
} else {
|
||||
wlv.char_attr = 0;
|
||||
}
|
||||
wlv.char_attr = decor_attr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2105,11 +2101,12 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
}
|
||||
ptr++;
|
||||
|
||||
decor_attr = 0;
|
||||
if (extra_check) {
|
||||
bool no_plain_buffer = (wp->w_s->b_p_spo_flags & SPO_NPBUFFER) != 0;
|
||||
bool can_spell = !no_plain_buffer;
|
||||
|
||||
// Get syntax attribute, unless still at the start of the line
|
||||
// Get extmark and syntax attributes, unless still at the start of the line
|
||||
// (double-wide char that doesn't fit).
|
||||
v = (ptr - line);
|
||||
if (has_syntax && v > 0) {
|
||||
@@ -2118,8 +2115,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
save_did_emsg = did_emsg;
|
||||
did_emsg = false;
|
||||
|
||||
syntax_attr = get_syntax_attr((colnr_T)v - 1,
|
||||
has_spell ? &can_spell : NULL, false);
|
||||
decor_attr = get_syntax_attr((colnr_T)v - 1,
|
||||
has_spell ? &can_spell : NULL, false);
|
||||
|
||||
if (did_emsg) { // -V547
|
||||
wp->w_s->b_syn_error = true;
|
||||
@@ -2137,17 +2134,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
line = ml_get_buf(wp->w_buffer, lnum, false);
|
||||
ptr = line + v;
|
||||
|
||||
if (!attr_pri) {
|
||||
if (wlv.cul_attr) {
|
||||
wlv.char_attr = 0 != wlv.line_attr_lowprio
|
||||
? hl_combine_attr(wlv.cul_attr, syntax_attr)
|
||||
: hl_combine_attr(syntax_attr, wlv.cul_attr);
|
||||
} else {
|
||||
wlv.char_attr = syntax_attr;
|
||||
}
|
||||
} else {
|
||||
wlv.char_attr = hl_combine_attr(syntax_attr, wlv.char_attr);
|
||||
}
|
||||
// no concealing past the end of the line, it interferes
|
||||
// with line highlighting.
|
||||
if (c == NUL) {
|
||||
@@ -2155,27 +2141,35 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
} else {
|
||||
syntax_flags = get_syntax_info(&syntax_seqnr);
|
||||
}
|
||||
} else if (!attr_pri) {
|
||||
wlv.char_attr = 0;
|
||||
}
|
||||
|
||||
if (has_decor && v > 0) {
|
||||
if (extmark_attr != 0) {
|
||||
if (!attr_pri) {
|
||||
wlv.char_attr = hl_combine_attr(wlv.char_attr, extmark_attr);
|
||||
} else {
|
||||
wlv.char_attr = hl_combine_attr(extmark_attr, wlv.char_attr);
|
||||
}
|
||||
}
|
||||
// extmarks take preceedence over syntax.c
|
||||
decor_attr = hl_combine_attr(decor_attr, extmark_attr);
|
||||
|
||||
decor_conceal = decor_state.conceal;
|
||||
if (decor_conceal && decor_state.conceal_char) {
|
||||
decor_conceal = 2; // really??
|
||||
}
|
||||
|
||||
can_spell = TRISTATE_TO_BOOL(decor_state.spell, can_spell);
|
||||
}
|
||||
|
||||
if (decor_attr) {
|
||||
if (!attr_pri) {
|
||||
if (wlv.cul_attr) {
|
||||
wlv.char_attr = 0 != wlv.line_attr_lowprio
|
||||
? hl_combine_attr(wlv.cul_attr, decor_attr)
|
||||
: hl_combine_attr(decor_attr, wlv.cul_attr);
|
||||
} else {
|
||||
wlv.char_attr = decor_attr;
|
||||
}
|
||||
} else {
|
||||
wlv.char_attr = hl_combine_attr(decor_attr, wlv.char_attr);
|
||||
}
|
||||
} else if (!attr_pri) {
|
||||
wlv.char_attr = 0;
|
||||
}
|
||||
|
||||
// Check spelling (unless at the end of the line).
|
||||
// Only do this when there is no syntax highlighting, the
|
||||
// @Spell cluster is not used or the current syntax item
|
||||
@@ -2186,8 +2180,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
char *prev_ptr = ptr - mb_l;
|
||||
// do not calculate cap_col at the end of the line or when
|
||||
// only white space is following
|
||||
if (c != 0 && (*skipwhite(prev_ptr) != NUL)
|
||||
&& ((!has_syntax && !no_plain_buffer) || can_spell)) {
|
||||
if (c != 0 && (*skipwhite(prev_ptr) != NUL) && can_spell) {
|
||||
char *p;
|
||||
hlf_T spell_hlf = HLF_COUNT;
|
||||
v -= mb_l - 1;
|
||||
|
Reference in New Issue
Block a user