tests: don't ignore highlights in searchhl_spec

This commit is contained in:
Björn Linse
2016-08-09 14:05:08 +02:00
parent 35b47890dd
commit 7b29fdd200

View File

@@ -11,12 +11,11 @@ describe('search highlighting', function()
clear() clear()
screen = Screen.new(40, 7) screen = Screen.new(40, 7)
screen:attach() screen:attach()
--ignore highligting of ~-lines
screen:set_default_attr_ignore( {{bold=true, foreground=colors.Blue}} )
screen:set_default_attr_ids( { screen:set_default_attr_ids( {
[1] = {background = colors.Yellow}, -- Search [1] = {bold=true, foreground=Screen.colors.Blue},
[2] = {reverse = true}, [2] = {background = colors.Yellow}, -- Search
[3] = {foreground = colors.Red}, -- Message [3] = {reverse = true},
[4] = {foreground = colors.Red}, -- Message
}) })
end) end)
@@ -27,10 +26,10 @@ describe('search highlighting', function()
screen:expect([[ screen:expect([[
some ^text | some ^text |
more text | more text |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
/text | /text |
]]) ]])
end) end)
@@ -46,35 +45,35 @@ describe('search highlighting', function()
-- 'hlsearch' is enabled by default. #2859 -- 'hlsearch' is enabled by default. #2859
feed("gg/text<cr>") feed("gg/text<cr>")
screen:expect([[ screen:expect([[
some {1:^text} | some {2:^text} |
more {1:text}stuff | more {2:text}stuff |
stupid{1:texttext}stuff | stupid{2:texttext}stuff |
a {1:text} word | a {2:text} word |
| |
~ | {1:~ }|
/text | /text |
]]) ]])
-- overlapping matches not allowed -- overlapping matches not allowed
feed("3nx") feed("3nx")
screen:expect([[ screen:expect([[
some {1:text} | some {2:text} |
more {1:text}stuff | more {2:text}stuff |
stupid{1:text}^extstuff | stupid{2:text}^extstuff |
a {1:text} word | a {2:text} word |
| |
~ | {1:~ }|
/text | /text |
]]) ]])
feed("ggn*") -- search for entire word feed("ggn*") -- search for entire word
screen:expect([[ screen:expect([[
some {1:text} | some {2:text} |
more textstuff | more textstuff |
stupidtextextstuff | stupidtextextstuff |
a {1:^text} word | a {2:^text} word |
| |
~ | {1:~ }|
/\<text\> | /\<text\> |
]]) ]])
@@ -85,7 +84,7 @@ describe('search highlighting', function()
stupidtextextstuff | stupidtextextstuff |
a ^text word | a ^text word |
| |
~ | {1:~ }|
:nohlsearch | :nohlsearch |
]]) ]])
end) end)
@@ -99,45 +98,45 @@ describe('search highlighting', function()
]]) ]])
feed("gg/li") feed("gg/li")
screen:expect([[ screen:expect([[
the first {2:li}ne | the first {3:li}ne |
in a little file | in a little file |
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
/li^ | /li^ |
]]) ]])
feed("t") feed("t")
screen:expect([[ screen:expect([[
the first line | the first line |
in a {2:lit}tle file | in a {3:lit}tle file |
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
/lit^ | /lit^ |
]]) ]])
feed("<cr>") feed("<cr>")
screen:expect([[ screen:expect([[
the first line | the first line |
in a {1:^lit}tle file | in a {2:^lit}tle file |
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
/lit | /lit |
]]) ]])
feed("/fir") feed("/fir")
screen:expect([[ screen:expect([[
the {2:fir}st line | the {3:fir}st line |
in a {1:lit}tle file | in a {2:lit}tle file |
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
/fir^ | /fir^ |
]]) ]])
@@ -145,11 +144,11 @@ describe('search highlighting', function()
feed("<esc>/ttle") feed("<esc>/ttle")
screen:expect([[ screen:expect([[
the first line | the first line |
in a {1:li}{2:ttle} file | in a {2:li}{3:ttle} file |
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
/ttle^ | /ttle^ |
]]) ]])
end) end)
@@ -163,12 +162,12 @@ describe('search highlighting', function()
feed("gg/mat/e") feed("gg/mat/e")
screen:expect([[ screen:expect([[
not the {2:mat}ch you're looking for | not the {3:mat}ch you're looking for |
the match is here | the match is here |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
/mat/e^ | /mat/e^ |
]]) ]])
@@ -176,22 +175,22 @@ describe('search highlighting', function()
feed("<esc>2/mat/e") feed("<esc>2/mat/e")
screen:expect([[ screen:expect([[
not the match you're looking for | not the match you're looking for |
the {2:mat}ch is here | the {3:mat}ch is here |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
/mat/e^ | /mat/e^ |
]]) ]])
feed("<cr>") feed("<cr>")
screen:expect([[ screen:expect([[
not the {1:mat}ch you're looking for | not the {2:mat}ch you're looking for |
the {1:ma^t}ch is here | the {2:ma^t}ch is here |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
/mat/e | /mat/e |
]]) ]])
end) end)
@@ -202,28 +201,37 @@ describe('search highlighting', function()
feed('/line\\na<cr>') feed('/line\\na<cr>')
screen:expect([[ screen:expect([[
| |
a repeated {1:^line} | a repeated {2:^line} |
{1:a} repeated {1:line} | {2:a} repeated {2:line} |
{1:a} repeated {1:line} | {2:a} repeated {2:line} |
{1:a} repeated line | {2:a} repeated line |
~ | {1:~ }|
{3:search hit BOTTOM, continuing at TOP} | {4:search hit BOTTOM, continuing at TOP} |
]]) ]])
-- it redraws rows above the changed one -- it redraws rows above the changed one
feed('4Grb') feed('4Grb')
screen:expect([[ screen:expect([[
| |
a repeated {1:line} | a repeated {2:line} |
{1:a} repeated line | {2:a} repeated line |
^b repeated {1:line} | ^b repeated {2:line} |
{1:a} repeated line | {2:a} repeated line |
~ | {1:~ }|
{3:search hit BOTTOM, continuing at TOP} | {4:search hit BOTTOM, continuing at TOP} |
]]) ]])
end) end)
it('works with matchadd and syntax', function() it('works with matchadd and syntax', function()
screen:set_default_attr_ids( {
[1] = {bold=true, foreground=Screen.colors.Blue},
[2] = {background = colors.Yellow},
[3] = {reverse = true},
[4] = {foreground = colors.Red},
[5] = {bold = true, background = colors.Green},
[6] = {italic = true, background = colors.Magenta},
[7] = {bold = true, background = colors.Yellow},
} )
execute('set hlsearch') execute('set hlsearch')
insert([[ insert([[
very special text very special text
@@ -238,25 +246,23 @@ describe('search highlighting', function()
-- is used (and matches with lower priorities are not combined) -- is used (and matches with lower priorities are not combined)
execute("/ial te") execute("/ial te")
screen:expect([[ screen:expect([[
very {4:spec^ial}{1: te}{5:xt} | very {5:spec^ial}{2: te}{6:xt} |
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
{3:search hit BOTTOM, continuing at TOP} | {4:search hit BOTTOM, continuing at TOP} |
]], {[1] = {background = colors.Yellow}, [2] = {reverse = true}, ]])
[3] = {foreground = colors.Red}, [4] = {bold = true, background =
colors.Green}, [5] = {italic = true, background = colors.Magenta}})
execute("call clearmatches()") execute("call clearmatches()")
screen:expect([[ screen:expect([[
very spec{1:^ial te}xt | very spec{2:^ial te}xt |
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
:call clearmatches() | :call clearmatches() |
]]) ]])
@@ -264,16 +270,14 @@ describe('search highlighting', function()
-- nonconflicting attributes are combined -- nonconflicting attributes are combined
execute("syntax keyword MyGroup special") execute("syntax keyword MyGroup special")
screen:expect([[ screen:expect([[
very {4:spec}{5:^ial}{1: te}xt | very {5:spec}{7:^ial}{2: te}xt |
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
:syntax keyword MyGroup special | :syntax keyword MyGroup special |
]], {[1] = {background = colors.Yellow}, [2] = {reverse = true}, ]])
[3] = {foreground = colors.Red}, [4] = {bold = true,
background = colors.Green}, [5] = {bold = true, background = colors.Yellow}})
end) end)
end) end)