Commit: patch 9.2.0111: 'winhighlight' option not always applied

1 view
Skip to first unread message

Christian Brabandt

unread,
Mar 5, 2026, 3:31:55 PM (2 days ago) Mar 5
to vim...@googlegroups.com
patch 9.2.0111: 'winhighlight' option not always applied

Commit: https://github.com/vim/vim/commit/0fe3ca6031a0cffc5fb16ae15e94fcda7b8a3b45
Author: Foxe Chen <chen...@gmail.com>
Date: Thu Mar 5 20:17:57 2026 +0000

patch 9.2.0111: 'winhighlight' option not always applied

Problem: 'winhighlight' option not always applied
Solution: Apply 'winhighlight' setting in more places
(Foxe Chen).

closes: #19555

Signed-off-by: Foxe Chen <chen...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/drawscreen.c b/src/drawscreen.c
index 92fd9a62c..bdaaaf0be 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -638,7 +638,6 @@ redraw_custom_statusline(win_T *wp)
void
showruler(int always)
{
- bool override_success;
if (!always && !redrawing())
return;
if (pum_visible())
@@ -647,15 +646,12 @@ showruler(int always)
curwin->w_redr_status = TRUE;
return;
}
- override_success = push_highlight_overrides(curwin->w_hl, curwin->w_hl_len);
#if defined(FEAT_STL_OPT)
if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height)
redraw_custom_statusline(curwin);
else
#endif
win_redr_ruler(curwin, always, FALSE);
- if (override_success)
- pop_highlight_overrides();

if (need_maketitle
#ifdef FEAT_STL_OPT
@@ -748,6 +744,8 @@ win_redr_ruler(win_T *wp, int always, int ignore_pum)
int this_ru_col;
int n1; // scratch value
int n2; // scratch value
+ bool override_success =
+ push_highlight_overrides(wp->w_hl, wp->w_hl_len);

cursor_off();
if (wp->w_status_height)
@@ -853,6 +851,9 @@ win_redr_ruler(win_T *wp, int always, int ignore_pum)
#ifdef FEAT_DIFF
wp->w_ru_topfill = wp->w_topfill;
#endif
+
+ if (override_success)
+ pop_highlight_overrides();
}
}

@@ -1033,6 +1034,8 @@ redraw_win_toolbar(win_T *wp)
int col = 0;
int next_col;
int off = (int)(current_ScreenLine - ScreenLines);
+ bool override_success =
+ push_highlight_overrides(wp->w_hl, wp->w_hl_len);
int fill_attr = syn_name2attr((char_u *)"ToolbarLine");
int button_attr = syn_name2attr((char_u *)"ToolbarButton");

@@ -1084,6 +1087,9 @@ redraw_win_toolbar(win_T *wp)

screen_line(wp, wp->w_winrow, wp->w_wincol, wp->w_width,
wp->w_width, -1, 0);
+
+ if (override_success)
+ pop_highlight_overrides();
}
#endif

@@ -1522,6 +1528,7 @@ win_update(win_T *wp)
#if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA)
int save_got_int;
#endif
+ bool override_success;

#if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
// This needs to be done only for the first window when update_screen() is
@@ -1571,6 +1578,9 @@ win_update(win_T *wp)
return;
}

+ override_success = push_highlight_overrides(wp->w_hl, wp->w_hl_len);
+
+
#ifdef FEAT_TERMINAL
// If this window contains a terminal, redraw works completely differently.
if (term_do_update_window(wp))
@@ -1582,6 +1592,8 @@ win_update(win_T *wp)
redraw_win_toolbar(wp);
# endif
wp->w_redr_type = 0;
+ if (override_success)
+ pop_highlight_overrides();
return;
}
#endif
@@ -2854,6 +2866,9 @@ win_update(win_T *wp)
if (!got_int)
got_int = save_got_int;
#endif
+
+ if (override_success)
+ pop_highlight_overrides();
}

#if defined(FEAT_NETBEANS_INTG) || defined(FEAT_GUI)
diff --git a/src/highlight.c b/src/highlight.c
index efd24b647..0bd5c6e4c 100644
--- a/src/highlight.c
+++ b/src/highlight.c
@@ -184,11 +184,11 @@ typedef struct
typedef struct hl_overrides_S hl_overrides_T;
struct hl_overrides_S
{
- hl_override_T *arr;
+ hl_override_T *arr; // May be NULL if "arr" was freed
int len;
- hl_overrides_T *next; // Used to handle recursive calls
+ hl_overrides_T *next; // Used to handle recursive calls

- int attr[HLF_COUNT]; // highlight_attr[] before being updated.
+ int attr[HLF_COUNT]; // highlight_attr[] before being updated.
};

static hl_overrides_T *overrides = NULL;
@@ -5478,6 +5478,25 @@ update_highlight_overrides(hl_override_T *old, hl_override_T *hl_new, int newlen
}
}

+/*
+ * If "arr" is in the highlight overrides list, then mark it as invalid.
+ */
+ void
+remove_highlight_overrides(hl_override_T *arr)
+{
+ if (arr == NULL || overrides == NULL)
+ return;
+
+ for (hl_overrides_T *set = overrides; set != NULL; set = set->next)
+ {
+ if (set->arr == arr)
+ {
+ set->arr = NULL;
+ break;
+ }
+ }
+}
+
/*
* Update highlight_attr[] array. If "update_ids" is true, then update
* highlight_ids[] array instead.
diff --git a/src/proto/highlight.pro b/src/proto/highlight.pro
index 46fb5dbbe..5d9231739 100644
--- a/src/proto/highlight.pro
+++ b/src/proto/highlight.pro
@@ -49,6 +49,7 @@ void free_highlight_fonts(void);
void f_hlget(typval_T *argvars, typval_T *rettv);
void f_hlset(typval_T *argvars, typval_T *rettv);
void update_highlight_overrides(hl_override_T *old, hl_override_T *hl_new, int newlen);
+void remove_highlight_overrides(hl_override_T *arr);
bool push_highlight_overrides(hl_override_T *arr, int len);
void pop_highlight_overrides(void);
char *update_winhighlight(win_T *wp, char_u *opt);
diff --git a/src/screen.c b/src/screen.c
index f6a8b4951..81becb984 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -117,7 +117,9 @@ conceal_check_cursor_line(int was_concealed)
int
get_win_attr(win_T *wp)
{
- int win_attr = wp->w_hlfwin_id;
+ int win_attr = wp->w_hlfwin_id;
+ bool override_success =
+ push_highlight_overrides(wp->w_hl, wp->w_hl_len);

if (win_attr != 0)
{
@@ -135,6 +137,9 @@ get_win_attr(win_T *wp)
win_attr = HL_ATTR(HLF_PNI); // Pmenu
}
#endif
+
+ if (override_success)
+ pop_highlight_overrides();
return win_attr;
}

@@ -190,6 +195,8 @@ win_draw_end(
int n = 0;
int attr = HL_ATTR(hl);
int win_attr = get_win_attr(wp);
+ bool override_success =
+ push_highlight_overrides(wp->w_hl, wp->w_hl_len);

attr = hl_combine_attr(win_attr, attr);

@@ -232,6 +239,9 @@ win_draw_end(
}

set_empty_rows(wp, row);
+
+ if (override_success)
+ pop_highlight_overrides();
}

#if defined(FEAT_FOLDING)
@@ -489,6 +499,8 @@ screen_line(
int clear_next = FALSE;
int char_cells; // 1: normal char
// 2: occupies two display cells
+ bool override_success =
+ push_highlight_overrides(wp->w_hl, wp->w_hl_len);

// Check for illegal row and col, just in case.
if (row >= Rows)
@@ -1061,6 +1073,9 @@ skip_opacity:
else
LineWraps[row] = FALSE;
}
+
+ if (override_success)
+ pop_highlight_overrides();
}

#if defined(FEAT_RIGHTLEFT)
@@ -1212,6 +1227,7 @@ win_redr_custom(
stl_hlrec_T *tabtab;
win_T *ewp;
int p_crb_save;
+ bool override_success = false;

// There is a tiny chance that this gets called recursively: When
// redrawing a status line triggers redrawing the ruler or tabline.
@@ -1234,6 +1250,8 @@ win_redr_custom(
}
else
{
+ override_success = push_highlight_overrides(wp->w_hl, wp->w_hl_len);
+
row = statusline_row(wp);
fillchar = fillchar_status(&attr, wp);
int in_status_line = wp->w_status_height != 0;
@@ -1387,6 +1405,8 @@ win_redr_custom(
}

theend:
+ if (override_success)
+ pop_highlight_overrides();
entered = FALSE;
}

@@ -4773,7 +4793,9 @@ get_trans_bufname(buf_T *buf)
int
fillchar_status(int *attr, win_T *wp)
{
- int fill;
+ int fill;
+ bool override_success =
+ push_highlight_overrides(wp->w_hl, wp->w_hl_len);

#ifdef FEAT_TERMINAL
if (bt_terminal(wp->w_buffer))
@@ -4801,6 +4823,9 @@ fillchar_status(int *attr, win_T *wp)
*attr = HL_ATTR(HLF_SNC);
fill = wp->w_fill_chars.stlnc;
}
+
+ if (override_success)
+ pop_highlight_overrides();
return fill;
}

@@ -4811,7 +4836,12 @@ fillchar_status(int *attr, win_T *wp)
int
fillchar_vsep(int *attr, win_T *wp)
{
+ bool override_success =
+ push_highlight_overrides(wp->w_hl, wp->w_hl_len);
*attr = HL_ATTR(HLF_C);
+ if (override_success)
+ pop_highlight_overrides();
+
if (*attr == 0 && wp->w_fill_chars.vert == ' ')
return '|';
else
diff --git a/src/version.c b/src/version.c
index 0590e75f7..8f3e6f25c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 111,
/**/
110,
/**/
diff --git a/src/window.c b/src/window.c
index a925fcc03..defcc70e6 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5986,6 +5986,7 @@ win_free(
ruby_window_free(wp);
#endif

+ remove_highlight_overrides(wp->w_hl);
vim_free(wp->w_hl);

clear_winopt(&wp->w_onebuf_opt);
Reply all
Reply to author
Forward
0 new messages