fix(ui2): unset Search highlighting (#36633)

Problem:
Trying to match the search highlight groups to the Normal highlight for
the window can fail when the message highlighting contains a fg/bg that
the Normal highlight doesn't (like an error message in cmd will have
ErrorMsg highlight instead of MsgArea - which is Normal in cmd.)

Solution:
Link the search highlight groups to an empty group in 'winhighlight'
thus disabling them instead of overriding them with Normal/MsgArea/etc.
This commit is contained in:
Oleh Volynets
2025-11-20 18:19:31 +01:00
committed by GitHub
parent e9b6474ae7
commit ea70d2ad85
2 changed files with 27 additions and 14 deletions

View File

@@ -440,21 +440,31 @@ describe('messages2', function()
end)
it('Search highlights only apply to pager', function()
screen:add_extra_attr_ids({
[100] = { background = Screen.colors.Blue1, foreground = Screen.colors.Red },
[101] = { background = Screen.colors.Red1, foreground = Screen.colors.Blue1 },
})
command('hi MsgArea guifg=Red guibg=Blue')
command('hi Search guifg=Blue guibg=Red')
command('set hlsearch shortmess+=s')
feed('/foo<CR>')
screen:expect([[
^ |
{1:~ }|*12
{9:E486: Pattern not found: foo}{100: }|
]])
command('set cmdheight=0 | echo "foo"')
feed('/foo')
screen:expect([[
^ |
{1:~ }|*12
{1:~ }{4:foo}|
]])
feed('g<lt>')
screen:expect([[
|
{1:~ }|*11
{1:~ }{4:foo}|
/foo^ |
]])
feed('<Esc>g<lt>/foo')
screen:expect([[
|
{1:~ }|*10
{3: }|
{10:foo} |
/foo^ |
{101:fo^o}{100: }|
]])
end)
end)