mirror of
https://github.com/neovim/neovim.git
synced 2025-12-12 17:42:37 +00:00
fix(ui2): hide search highlights in msg window #36626
fix(ui2): hide search highlights in msg window. Problem: Search highlighting is shown in the msg (and dialog) window. Solution: Hide search highlighting in all but the pager window.
This commit is contained in:
@@ -80,12 +80,12 @@ function M.check_targets()
|
|||||||
api.nvim_set_option_value('modifiable', true, { scope = 'local' })
|
api.nvim_set_option_value('modifiable', true, { scope = 'local' })
|
||||||
api.nvim_set_option_value('bufhidden', 'hide', { scope = 'local' })
|
api.nvim_set_option_value('bufhidden', 'hide', { scope = 'local' })
|
||||||
api.nvim_set_option_value('buftype', 'nofile', { scope = 'local' })
|
api.nvim_set_option_value('buftype', 'nofile', { scope = 'local' })
|
||||||
if type ~= 'msg' then
|
-- Use MsgArea except in the msg window. Hide Search highlighting except in the pager.
|
||||||
-- Use MsgArea and hide search highlighting in the cmdline window.
|
local hide = type == 'msg' and 'NormalFloat' or 'MsgArea'
|
||||||
local hl = 'Normal:MsgArea'
|
hide = ('Search:%s,CurSearch:%s,IncSearch:%s'):format(hide, hide, hide)
|
||||||
hl = hl .. (type == 'cmd' and ',Search:MsgArea,CurSearch:MsgArea,IncSearch:MsgArea' or '')
|
local hl = type == 'msg' and '' or 'Normal:MsgArea' .. (type ~= 'pager' and ',' or '')
|
||||||
api.nvim_set_option_value('winhighlight', hl, { scope = 'local' })
|
hl = hl .. (type ~= 'pager' and hide or '')
|
||||||
end
|
api.nvim_set_option_value('winhighlight', hl, { scope = 'local' })
|
||||||
end)
|
end)
|
||||||
api.nvim_buf_set_name(M.bufs[type], ('[%s]'):format(type:sub(1, 1):upper() .. type:sub(2)))
|
api.nvim_buf_set_name(M.bufs[type], ('[%s]'):format(type:sub(1, 1):upper() .. type:sub(2)))
|
||||||
-- Fire FileType with window context to let the user reconfigure local options.
|
-- Fire FileType with window context to let the user reconfigure local options.
|
||||||
|
|||||||
@@ -438,4 +438,23 @@ describe('messages2', function()
|
|||||||
]])
|
]])
|
||||||
t.eq({ filetype = 4 }, n.eval('g:set')) -- still fires for 'filetype'
|
t.eq({ filetype = 4 }, n.eval('g:set')) -- still fires for 'filetype'
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('Search highlights only apply to pager', function()
|
||||||
|
command('set cmdheight=0 | echo "foo"')
|
||||||
|
feed('/foo')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|*11
|
||||||
|
{1:~ }{4:foo}|
|
||||||
|
/foo^ |
|
||||||
|
]])
|
||||||
|
feed('<Esc>g<lt>/foo')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
{1:~ }|*10
|
||||||
|
{3: }|
|
||||||
|
{10:foo} |
|
||||||
|
/foo^ |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user