New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RDY] hl-Syntax should override cursorline and cursorcolumn #6380
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2207,6 +2207,8 @@ win_line ( | |
int prev_c1 = 0; /* first composing char for prev_c */ | ||
int did_line_attr = 0; | ||
|
||
int line_attr_low_priority = 0; // attribute for current line | ||
// with very low priority | ||
bool search_attr_from_match = false; // if search_attr is from :match | ||
bool has_bufhl = false; // this buffer has highlight matches | ||
int bufhl_attr = 0; // attributes desired by bufhl | ||
|
@@ -2421,10 +2423,18 @@ win_line ( | |
filler_lines = wp->w_topfill; | ||
filler_todo = filler_lines; | ||
|
||
/* If this line has a sign with line highlighting set line_attr. */ | ||
// Cursor line highlighting for 'cursorline' in the current window. Not | ||
// when Visual mode is active, because it's not clear what is selected | ||
// then. | ||
if (wp->w_p_cul && lnum == wp->w_cursor.lnum | ||
&& !(wp == curwin && VIsual_active)) { | ||
line_attr_low_priority = win_hl_attr(wp, HLF_CUL); | ||
} | ||
|
||
v = buf_getsigntype(wp->w_buffer, lnum, SIGN_LINEHL); | ||
if (v != 0) | ||
line_attr = sign_get_attr((int)v, TRUE); | ||
if (v != 0) { | ||
line_attr = sign_get_attr((int)v, true); | ||
} | ||
|
||
// Highlight the current line in the quickfix window. | ||
if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum) { | ||
|
@@ -2435,7 +2445,7 @@ win_line ( | |
line_attr = hl_combine_attr(wp->w_hl_attr_normal, line_attr); | ||
} | ||
|
||
if (line_attr != 0) { | ||
if (line_attr_low_priority || line_attr) { | ||
area_highlighting = true; | ||
} | ||
|
||
|
@@ -2653,20 +2663,6 @@ win_line ( | |
cur = cur->next; | ||
} | ||
|
||
/* Cursor line highlighting for 'cursorline' in the current window. Not | ||
* when Visual mode is active, because it's not clear what is selected | ||
* then. */ | ||
if (wp->w_p_cul && lnum == wp->w_cursor.lnum | ||
&& !(wp == curwin && VIsual_active)) { | ||
if (line_attr != 0 && !(State & INSERT) && bt_quickfix(wp->w_buffer) | ||
&& qf_current_entry(wp) == lnum) { | ||
line_attr = hl_combine_attr(win_hl_attr(wp, HLF_CUL), line_attr); | ||
} else { | ||
line_attr = win_hl_attr(wp, HLF_CUL); | ||
} | ||
area_highlighting = true; | ||
} | ||
|
||
off = (unsigned)(current_ScreenLine - ScreenLines); | ||
col = 0; | ||
if (wp->w_p_rl) { | ||
|
@@ -3580,13 +3576,14 @@ win_line ( | |
// character if the line break is included. | ||
// For a diff line the highlighting continues after the | ||
// "$". | ||
if (diff_hlf == (hlf_T)0 && line_attr == 0) { | ||
/* In virtualedit, visual selections may extend | ||
* beyond end of line. */ | ||
if (diff_hlf == (hlf_T)0 | ||
&& line_attr == 0 | ||
&& line_attr_low_priority == 0) { | ||
// In virtualedit, visual selections may extend beyond end of line | ||
if (area_highlighting && virtual_active() | ||
&& tocol != MAXCOL && vcol < tocol) | ||
&& tocol != MAXCOL && vcol < tocol) { | ||
n_extra = 0; | ||
else { | ||
} else { | ||
p_extra = at_end_str; | ||
n_extra = 1; | ||
c_extra = NUL; | ||
|
@@ -3644,7 +3641,7 @@ win_line ( | |
(col < wp->w_width))) { | ||
c = ' '; | ||
ptr--; // put it back at the NUL | ||
} else if ((diff_hlf != (hlf_T)0 || line_attr != 0) | ||
} else if ((diff_hlf != (hlf_T)0 || line_attr_low_priority || line_attr) | ||
&& (wp->w_p_rl | ||
? (col >= 0) | ||
: (col - boguscols < wp->w_width))) { | ||
|
@@ -3656,7 +3653,8 @@ win_line ( | |
did_line_attr++; | ||
|
||
// don't do search HL for the rest of the line | ||
if (line_attr != 0 && char_attr == search_attr && col > 0) { | ||
if ((line_attr_low_priority || line_attr) | ||
&& char_attr == search_attr && col > 0) { | ||
char_attr = line_attr; | ||
} | ||
if (diff_hlf == HLF_TXD) { | ||
|
@@ -4018,13 +4016,16 @@ win_line ( | |
if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol | ||
&& lnum != wp->w_cursor.lnum) { | ||
vcol_save_attr = char_attr; | ||
char_attr = hl_combine_attr(char_attr, win_hl_attr(wp, HLF_CUC)); | ||
char_attr = hl_combine_attr(win_hl_attr(wp, HLF_CUC), char_attr); | ||
} else if (draw_color_col && VCOL_HLC == *color_cols) { | ||
vcol_save_attr = char_attr; | ||
char_attr = hl_combine_attr(char_attr, win_hl_attr(wp, HLF_MC)); | ||
char_attr = hl_combine_attr(win_hl_attr(wp, HLF_MC), char_attr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be a separate change, right? And it's much lower-risk than the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. They can fix the problem for |
||
} | ||
} | ||
|
||
// apply line attr with lowest priority so that everthing can override it | ||
char_attr = hl_combine_attr(line_attr_low_priority, char_attr); | ||
|
||
/* | ||
* Store character to be displayed. | ||
* Skip characters that are left of the screen for 'nowrap'. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this branch needed anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old one basically says if we are in quickfix window, then we use
HLF_CUL
to complement currentline_attr
, otherwise it will directly setline_attr
toHLF_CUL
. Settingline_attr
toHLF_CUL
is not what we want, since it incorrectly override some highlights under some condition (the logic is complex here)....In this patch, I split
line_attr
intoline_attr
andline_attr_low_priority
. Nowline_attr_low_priority
only takes care ofcursorline
, and it will be merged intochar_attr
with lowest priority. For otherline_attr
, it will still use the old logic. Sinceline_attr_low_priority
already has lowest priority, I believe these lines are not necessary.