test: Add a test for the new guisp highlighting feature.

Screen.lua needed a little cosmetical adjustment to print out the color nicely.
This commit is contained in:
KillTheMule
2016-04-24 11:46:48 +02:00
committed by AdnoC
parent f6a82c1d4f
commit a5ac389e5c
2 changed files with 59 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local os = require('os')
local clear, feed = helpers.clear, helpers.feed
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, request, eq = helpers.execute, helpers.request, helpers.eq
@@ -303,3 +303,60 @@ describe('Default highlight groups', function()
]], {[1] = {foreground = Screen.colors.Red, background = Screen.colors.Green}})
end)
end)
describe('New special highlight color attribute', function()
local screen
before_each(function()
clear()
screen = Screen.new(25,10)
screen:attach()
screen:set_default_attr_ignore({
[1] = {bold=true},
[2] = {bold=true, foreground=Screen.colors.Blue}
})
end)
it('used for undercurls', function()
execute('syntax on')
execute('syn keyword TmpKeyword neovim')
execute('syn keyword TmpKeyword1 special')
execute('syn keyword TmpKeyword2 specialwithbg')
execute('syn keyword TmpKeyword3 specialwithfg')
execute('hi! Awesome guifg=red guibg=yellow guisp=red')
execute('hi! Awesome1 guisp=red')
execute('hi! Awesome2 guibg=yellow guisp=red')
execute('hi! Awesome3 guifg=red guisp=red')
execute('hi link TmpKeyword Awesome')
execute('hi link TmpKeyword1 Awesome1')
execute('hi link TmpKeyword2 Awesome2')
execute('hi link TmpKeyword3 Awesome3')
insert([[
neovim
awesome neovim
wordcontainingneovim
special
specialwithbg
specialwithfg
]])
feed('Go<tab>neovim tabbed')
screen:expect([[
{1:neovim} |
awesome {1:neovim} |
wordcontainingneovim |
special |
{2:specialwithbg} |
{3:specialwithfg} |
|
{1:neovim} tabbed^ |
~ |
-- INSERT -- |
]],{
[1] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red,
special = Screen.colors.Red},
[2] = {special = Screen.colors.Red, background = Screen.colors.Yellow},
[3] = {foreground = Screen.colors.Red, special = Screen.colors.Red}
})
end)
end)

View File

@@ -577,7 +577,7 @@ function Screen:_pprint_attrs(attrs)
local items = {}
for f, v in pairs(attrs) do
local desc = tostring(v)
if f == "foreground" or f == "background" then
if f == "foreground" or f == "background" or f == "special" then
if Screen.colornames[v] ~= nil then
desc = "Screen.colors."..Screen.colornames[v]
end