mirror of
https://github.com/neovim/neovim.git
synced 2026-05-01 11:34:56 +00:00
refactor(drawline): integrate terminal hl with eol loop (#27893)
There is no test for using 'cursorline' in Normal mode in a terminal buffer, so add a test and fix 'cursorcolumn' remaining when entering Terminal mode. Also move synIDattr() tests to ui/highlight_spec.lua.
This commit is contained in:
@@ -2537,3 +2537,115 @@ describe('highlight namespaces', function()
|
||||
}
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('synIDattr()', function()
|
||||
local screen
|
||||
before_each(function()
|
||||
clear()
|
||||
screen = Screen.new(50, 7)
|
||||
command('highlight Normal ctermfg=252 guifg=#ff0000 guibg=Black')
|
||||
-- Salmon #fa8072 Maroon #800000
|
||||
command(
|
||||
'highlight Keyword ctermfg=79 guifg=Salmon guisp=Maroon cterm=strikethrough gui=strikethrough'
|
||||
)
|
||||
end)
|
||||
|
||||
it('returns cterm-color if RGB-capable UI is _not_ attached', function()
|
||||
eq('252', eval('synIDattr(hlID("Normal"), "fg")'))
|
||||
eq('252', eval('synIDattr(hlID("Normal"), "fg#")'))
|
||||
eq('', eval('synIDattr(hlID("Normal"), "bg")'))
|
||||
eq('', eval('synIDattr(hlID("Normal"), "bg#")'))
|
||||
eq('79', eval('synIDattr(hlID("Keyword"), "fg")'))
|
||||
eq('79', eval('synIDattr(hlID("Keyword"), "fg#")'))
|
||||
eq('', eval('synIDattr(hlID("Keyword"), "sp")'))
|
||||
eq('', eval('synIDattr(hlID("Keyword"), "sp#")'))
|
||||
end)
|
||||
|
||||
it('returns gui-color if "gui" arg is passed', function()
|
||||
eq('Black', eval('synIDattr(hlID("Normal"), "bg", "gui")'))
|
||||
eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp", "gui")'))
|
||||
end)
|
||||
|
||||
it('returns gui-color if RGB-capable UI is attached', function()
|
||||
screen:attach({ rgb = true })
|
||||
eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg")'))
|
||||
eq('Black', eval('synIDattr(hlID("Normal"), "bg")'))
|
||||
eq('Salmon', eval('synIDattr(hlID("Keyword"), "fg")'))
|
||||
eq('Maroon', eval('synIDattr(hlID("Keyword"), "sp")'))
|
||||
end)
|
||||
|
||||
it('returns #RRGGBB value for fg#/bg#/sp#', function()
|
||||
screen:attach({ rgb = true })
|
||||
eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg#")'))
|
||||
eq('#000000', eval('synIDattr(hlID("Normal"), "bg#")'))
|
||||
eq('#fa8072', eval('synIDattr(hlID("Keyword"), "fg#")'))
|
||||
eq('#800000', eval('synIDattr(hlID("Keyword"), "sp#")'))
|
||||
end)
|
||||
|
||||
it('returns color number if non-GUI', function()
|
||||
screen:attach({ rgb = false })
|
||||
eq('252', eval('synIDattr(hlID("Normal"), "fg")'))
|
||||
eq('79', eval('synIDattr(hlID("Keyword"), "fg")'))
|
||||
end)
|
||||
|
||||
it('returns "1" if group has given highlight attribute', function()
|
||||
local hl_attrs = {
|
||||
'underline',
|
||||
'undercurl',
|
||||
'underdouble',
|
||||
'underdotted',
|
||||
'underdashed',
|
||||
'strikethrough',
|
||||
}
|
||||
for _, hl_attr in ipairs(hl_attrs) do
|
||||
local context = 'using ' .. hl_attr .. ' attr'
|
||||
command('highlight Keyword cterm=' .. hl_attr .. ' gui=' .. hl_attr)
|
||||
eq('', eval('synIDattr(hlID("Normal"), "' .. hl_attr .. '")'), context)
|
||||
eq('1', eval('synIDattr(hlID("Keyword"), "' .. hl_attr .. '")'), context)
|
||||
eq('1', eval('synIDattr(hlID("Keyword"), "' .. hl_attr .. '", "gui")'), context)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('fg/bg special colors', function()
|
||||
local screen
|
||||
before_each(function()
|
||||
clear()
|
||||
screen = Screen.new(50, 7)
|
||||
command('highlight Normal ctermfg=145 ctermbg=16 guifg=#ff0000 guibg=Black')
|
||||
command('highlight Visual ctermfg=bg ctermbg=fg guifg=bg guibg=fg guisp=bg')
|
||||
end)
|
||||
|
||||
it('resolve to "Normal" values', function()
|
||||
eq(eval('synIDattr(hlID("Normal"), "bg")'), eval('synIDattr(hlID("Visual"), "fg")'))
|
||||
eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "fg#")'))
|
||||
eq(eval('synIDattr(hlID("Normal"), "fg")'), eval('synIDattr(hlID("Visual"), "bg")'))
|
||||
eq(eval('synIDattr(hlID("Normal"), "fg#")'), eval('synIDattr(hlID("Visual"), "bg#")'))
|
||||
eq('bg', eval('synIDattr(hlID("Visual"), "fg", "gui")'))
|
||||
eq('bg', eval('synIDattr(hlID("Visual"), "fg#", "gui")'))
|
||||
eq('fg', eval('synIDattr(hlID("Visual"), "bg", "gui")'))
|
||||
eq('fg', eval('synIDattr(hlID("Visual"), "bg#", "gui")'))
|
||||
eq('bg', eval('synIDattr(hlID("Visual"), "sp", "gui")'))
|
||||
eq('bg', eval('synIDattr(hlID("Visual"), "sp#", "gui")'))
|
||||
end)
|
||||
|
||||
it('resolve to "Normal" values in RGB-capable UI', function()
|
||||
screen:attach({ rgb = true })
|
||||
eq('bg', eval('synIDattr(hlID("Visual"), "fg")'))
|
||||
eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "fg#")'))
|
||||
eq('fg', eval('synIDattr(hlID("Visual"), "bg")'))
|
||||
eq(eval('synIDattr(hlID("Normal"), "fg#")'), eval('synIDattr(hlID("Visual"), "bg#")'))
|
||||
eq('bg', eval('synIDattr(hlID("Visual"), "sp")'))
|
||||
eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "sp#")'))
|
||||
end)
|
||||
|
||||
it('resolve after the "Normal" group is modified', function()
|
||||
screen:attach({ rgb = true })
|
||||
local new_guibg = '#282c34'
|
||||
local new_guifg = '#abb2bf'
|
||||
command('highlight Normal guifg=' .. new_guifg .. ' guibg=' .. new_guibg)
|
||||
eq(new_guibg, eval('synIDattr(hlID("Visual"), "fg#")'))
|
||||
eq(new_guifg, eval('synIDattr(hlID("Visual"), "bg#")'))
|
||||
eq(new_guibg, eval('synIDattr(hlID("Visual"), "sp#")'))
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user