mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(highlight): 'winhl' shouldn't take priority over API (#31288)
This commit is contained in:
parent
92a83f671b
commit
ff75f345ab
@ -476,6 +476,7 @@ void nvim_win_set_hl_ns(Window window, Integer ns_id, Error *err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
win->w_ns_hl = (NS)ns_id;
|
win->w_ns_hl = (NS)ns_id;
|
||||||
|
win->w_ns_hl_winhl = -1;
|
||||||
win->w_hl_needs_update = true;
|
win->w_hl_needs_update = true;
|
||||||
redraw_later(win, UPD_NOT_VALID);
|
redraw_later(win, UPD_NOT_VALID);
|
||||||
}
|
}
|
||||||
|
@ -1035,7 +1035,7 @@ struct window_S {
|
|||||||
synblock_T *w_s; ///< for :ownsyntax
|
synblock_T *w_s; ///< for :ownsyntax
|
||||||
|
|
||||||
int w_ns_hl;
|
int w_ns_hl;
|
||||||
int w_ns_hl_winhl;
|
int w_ns_hl_winhl; ///< when set to -1, 'winhighlight' shouldn't be used
|
||||||
int w_ns_hl_active;
|
int w_ns_hl_active;
|
||||||
int *w_ns_hl_attr;
|
int *w_ns_hl_attr;
|
||||||
|
|
||||||
|
@ -1736,8 +1736,14 @@ bool parse_winhl_opt(const char *winhl, win_T *wp)
|
|||||||
p = wp->w_p_winhl;
|
p = wp->w_p_winhl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wp != NULL && wp->w_ns_hl_winhl < 0) {
|
||||||
|
// 'winhighlight' shouldn't be used for this window.
|
||||||
|
// Only check that the value is valid.
|
||||||
|
wp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!*p) {
|
if (!*p) {
|
||||||
if (wp != NULL && wp->w_ns_hl_winhl && wp->w_ns_hl == wp->w_ns_hl_winhl) {
|
if (wp != NULL && wp->w_ns_hl_winhl > 0 && wp->w_ns_hl == wp->w_ns_hl_winhl) {
|
||||||
wp->w_ns_hl = 0;
|
wp->w_ns_hl = 0;
|
||||||
wp->w_hl_needs_update = true;
|
wp->w_hl_needs_update = true;
|
||||||
}
|
}
|
||||||
|
@ -710,4 +710,18 @@ describe('API: set/get highlight namespace', function()
|
|||||||
api.nvim_win_set_hl_ns(0, ns)
|
api.nvim_win_set_hl_ns(0, ns)
|
||||||
eq(ns, api.nvim_get_hl_ns({ winid = 0 }))
|
eq(ns, api.nvim_get_hl_ns({ winid = 0 }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('setting namespace takes priority over &winhighlight', function()
|
||||||
|
command('set winhighlight=Visual:Search')
|
||||||
|
n.insert('foobar')
|
||||||
|
local ns = api.nvim_create_namespace('')
|
||||||
|
api.nvim_win_set_hl_ns(0, ns)
|
||||||
|
eq(ns, api.nvim_get_hl_ns({ winid = 0 }))
|
||||||
|
command('enew') -- switching buffer keeps namespace #30904
|
||||||
|
eq(ns, api.nvim_get_hl_ns({ winid = 0 }))
|
||||||
|
command('set winhighlight=')
|
||||||
|
eq(ns, api.nvim_get_hl_ns({ winid = 0 }))
|
||||||
|
command('set winhighlight=Visual:Search')
|
||||||
|
eq(ns, api.nvim_get_hl_ns({ winid = 0 }))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user