mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
tests/ui: cleanup illegitimate usages of "attr_ignore"
"attr_ignore" is an anti-pattern, with snapshot_util() just include all the highlights already.
This commit is contained in:
@@ -14,6 +14,10 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
|
||||
it('is working', function()
|
||||
local screen = Screen.new(40, 5)
|
||||
screen:attach()
|
||||
screen:set_default_attr_ids({
|
||||
[0] = {bold = true, foreground = Screen.colors.Blue},
|
||||
[1] = {background = Screen.colors.Red},
|
||||
})
|
||||
|
||||
-- Check that "matcharg()" returns the correct group and pattern if a match
|
||||
-- is defined.
|
||||
@@ -126,22 +130,22 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
|
||||
command("call matchaddpos('MyGroup1', [[1, 5], [1, 8, 3]], 10, 3)")
|
||||
screen:expect([[
|
||||
abcd{1:e}fg{1:hij}klmnop^q |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]], {[1] = {background = Screen.colors.Red}}, {{bold = true, foreground = Screen.colors.Blue}})
|
||||
]])
|
||||
|
||||
command("call clearmatches()")
|
||||
command("call setline(1, 'abcdΣabcdef')")
|
||||
command("call matchaddpos('MyGroup1', [[1, 4, 2], [1, 9, 2]])")
|
||||
screen:expect([[
|
||||
abc{1:dΣ}ab{1:cd}e^f |
|
||||
~ |
|
||||
~ |
|
||||
~ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]],{[1] = {background = Screen.colors.Red}}, {{bold = true, foreground = Screen.colors.Blue}})
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
||||
|
@@ -408,10 +408,7 @@ describe('search cmdline', function()
|
||||
screen = Screen.new(20, 6)
|
||||
screen:attach()
|
||||
screen:set_default_attr_ids({
|
||||
inc = {reverse = true}
|
||||
})
|
||||
screen:set_default_attr_ignore({
|
||||
{bold=true, reverse=true}, {bold=true, foreground=Screen.colors.Blue1}
|
||||
inc = {reverse = true},
|
||||
})
|
||||
tenlines()
|
||||
|
||||
|
@@ -116,8 +116,6 @@ describe('health.vim', function()
|
||||
screen:set_default_attr_ids({
|
||||
Ok = { foreground = Screen.colors.Grey3, background = 6291200 },
|
||||
Error = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
|
||||
})
|
||||
screen:set_default_attr_ignore({
|
||||
Heading = { bold=true, foreground=Screen.colors.Magenta },
|
||||
Heading2 = { foreground = Screen.colors.SlateBlue },
|
||||
Bar = { foreground=Screen.colors.Purple },
|
||||
@@ -126,18 +124,18 @@ describe('health.vim', function()
|
||||
command("checkhealth foo success1")
|
||||
command("1tabclose")
|
||||
command("set laststatus=0")
|
||||
screen:expect([[
|
||||
screen:expect{grid=[[
|
||||
^ |
|
||||
health#foo#check |
|
||||
========================================================================|
|
||||
- {Error:ERROR:} No healthcheck found for "foo" plugin. |
|
||||
{Heading:health#foo#check} |
|
||||
{Bar:========================================================================}|
|
||||
{Bullet: -} {Error:ERROR:} No healthcheck found for "foo" plugin. |
|
||||
|
|
||||
health#success1#check |
|
||||
========================================================================|
|
||||
## report 1 |
|
||||
- {Ok:OK:} everything is fine |
|
||||
{Heading:health#success1#check} |
|
||||
{Bar:========================================================================}|
|
||||
{Heading2:##}{Heading: report 1} |
|
||||
{Bullet: -} {Ok:OK:} everything is fine |
|
||||
|
|
||||
]])
|
||||
]]}
|
||||
end)
|
||||
|
||||
it("gracefully handles invalid healthcheck", function()
|
||||
|
@@ -19,10 +19,8 @@ describe(':Man', function()
|
||||
u = { underline = true },
|
||||
bi = { bold = true, italic = true },
|
||||
biu = { bold = true, italic = true, underline = true },
|
||||
})
|
||||
screen:set_default_attr_ignore({
|
||||
{ foreground = Screen.colors.Blue }, -- control chars
|
||||
{ bold = true, foreground = Screen.colors.Blue } -- empty line '~'s
|
||||
c = { foreground = Screen.colors.Blue }, -- control chars
|
||||
eob = { bold = true, foreground = Screen.colors.Blue } -- empty line '~'s
|
||||
})
|
||||
screen:attach()
|
||||
end)
|
||||
@@ -36,21 +34,21 @@ describe(':Man', function()
|
||||
ithis i<C-v><C-h>is<C-v><C-h>s a<C-v><C-h>a test
|
||||
with _<C-v><C-h>o_<C-v><C-h>v_<C-v><C-h>e_<C-v><C-h>r_<C-v><C-h>s_<C-v><C-h>t_<C-v><C-h>r_<C-v><C-h>u_<C-v><C-h>c_<C-v><C-h>k text<ESC>]])
|
||||
|
||||
screen:expect([[
|
||||
this i^His^Hs a^Ha test |
|
||||
with _^Ho_^Hv_^He_^Hr_^Hs_^Ht_^Hr_^Hu_^Hc_^Hk tex^t |
|
||||
~ |
|
||||
~ |
|
||||
|
|
||||
]])
|
||||
screen:expect{grid=[[
|
||||
this i{c:^H}is{c:^H}s a{c:^H}a test |
|
||||
with _{c:^H}o_{c:^H}v_{c:^H}e_{c:^H}r_{c:^H}s_{c:^H}t_{c:^H}r_{c:^H}u_{c:^H}c_{c:^H}k tex^t |
|
||||
{eob:~ }|
|
||||
{eob:~ }|
|
||||
|
|
||||
]]}
|
||||
|
||||
eval('man#init_pager()')
|
||||
|
||||
screen:expect([[
|
||||
^this {b:is} {b:a} test |
|
||||
with {u:overstruck} text |
|
||||
~ |
|
||||
~ |
|
||||
{eob:~ }|
|
||||
{eob:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
@@ -60,21 +58,21 @@ describe(':Man', function()
|
||||
ithis <C-v><ESC>[1mis <C-v><ESC>[3ma <C-v><ESC>[4mtest<C-v><ESC>[0m
|
||||
<C-v><ESC>[4mwith<C-v><ESC>[24m <C-v><ESC>[4mescaped<C-v><ESC>[24m <C-v><ESC>[4mtext<C-v><ESC>[24m<ESC>]])
|
||||
|
||||
screen:expect([=[
|
||||
this ^[[1mis ^[[3ma ^[[4mtest^[[0m |
|
||||
^[[4mwith^[[24m ^[[4mescaped^[[24m ^[[4mtext^[[24^m |
|
||||
~ |
|
||||
~ |
|
||||
|
|
||||
]=])
|
||||
screen:expect{grid=[=[
|
||||
this {c:^[}[1mis {c:^[}[3ma {c:^[}[4mtest{c:^[}[0m |
|
||||
{c:^[}[4mwith{c:^[}[24m {c:^[}[4mescaped{c:^[}[24m {c:^[}[4mtext{c:^[}[24^m |
|
||||
{eob:~ }|
|
||||
{eob:~ }|
|
||||
|
|
||||
]=]}
|
||||
|
||||
eval('man#init_pager()')
|
||||
|
||||
screen:expect([[
|
||||
^this {b:is }{bi:a }{biu:test} |
|
||||
{u:with} {u:escaped} {u:text} |
|
||||
~ |
|
||||
~ |
|
||||
{eob:~ }|
|
||||
{eob:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
@@ -88,8 +86,8 @@ describe(':Man', function()
|
||||
screen:expect([[
|
||||
^this {b:is} {b:あ} test |
|
||||
with {u:överstrũck} te{i:xt¶} |
|
||||
~ |
|
||||
~ |
|
||||
{eob:~ }|
|
||||
{eob:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
@@ -105,7 +103,7 @@ describe(':Man', function()
|
||||
{b:^_begins} |
|
||||
{b:mid_dle} |
|
||||
{u:mid_dle} |
|
||||
~ |
|
||||
{eob:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
@@ -121,7 +119,7 @@ describe(':Man', function()
|
||||
^· {b:·} |
|
||||
{b:·} |
|
||||
{b:·} double |
|
||||
~ |
|
||||
{eob:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
@@ -88,6 +88,11 @@ describe('clipboard', function()
|
||||
before_each(function()
|
||||
clear()
|
||||
screen = Screen.new(72, 4)
|
||||
screen:set_default_attr_ids({
|
||||
[0] = {bold = true, foreground = Screen.colors.Blue},
|
||||
[1] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
|
||||
[2] = {bold = true, foreground = Screen.colors.SeaGreen4},
|
||||
})
|
||||
screen:attach()
|
||||
command("set display-=msgsep")
|
||||
end)
|
||||
@@ -103,22 +108,22 @@ describe('clipboard', function()
|
||||
feed_command('redir @+> | :silent echo system("cat CONTRIBUTING.md") | redir END')
|
||||
screen:expect([[
|
||||
^ |
|
||||
~ |
|
||||
~ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
|
||||
]], nil, {{bold = true, foreground = Screen.colors.Blue}})
|
||||
]])
|
||||
end)
|
||||
|
||||
it('`:redir @+>|bogus_cmd|redir END` + invalid g:clipboard must not recurse #7184',
|
||||
function()
|
||||
command("let g:clipboard = 'bogus'")
|
||||
feed_command('redir @+> | bogus_cmd | redir END')
|
||||
screen:expect([[
|
||||
~ |
|
||||
screen:expect{grid=[[
|
||||
{0:~ }|
|
||||
clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
|
||||
E492: Not an editor command: bogus_cmd | redir END |
|
||||
Press ENTER or type command to continue^ |
|
||||
]], nil, {{bold = true, foreground = Screen.colors.Blue}})
|
||||
{1:E492: Not an editor command: bogus_cmd | redir END} |
|
||||
{2:Press ENTER or type command to continue}^ |
|
||||
]]}
|
||||
end)
|
||||
|
||||
it('invalid g:clipboard shows hint if :redir is not active', function()
|
||||
@@ -131,10 +136,10 @@ describe('clipboard', function()
|
||||
feed_command('let @+="foo"')
|
||||
screen:expect([[
|
||||
^ |
|
||||
~ |
|
||||
~ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
|
||||
]], nil, {{bold = true, foreground = Screen.colors.Blue}})
|
||||
]])
|
||||
end)
|
||||
|
||||
it('valid g:clipboard', function()
|
||||
@@ -266,13 +271,17 @@ describe('clipboard (with fake clipboard.vim)', function()
|
||||
function()
|
||||
local screen = Screen.new(72, 4)
|
||||
screen:attach()
|
||||
screen:set_default_attr_ids({
|
||||
[0] = {bold = true, foreground = Screen.colors.Blue},
|
||||
[1] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
|
||||
})
|
||||
feed_command('redir @+> | bogus_cmd | redir END')
|
||||
screen:expect([[
|
||||
^ |
|
||||
~ |
|
||||
~ |
|
||||
E492: Not an editor command: bogus_cmd | redir END |
|
||||
]], nil, {{bold = true, foreground = Screen.colors.Blue}})
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{1:E492: Not an editor command: bogus_cmd | redir END} |
|
||||
]])
|
||||
end)
|
||||
|
||||
it('has independent "* and unnamed registers by default', function()
|
||||
@@ -637,6 +646,9 @@ describe('clipboard (with fake clipboard.vim)', function()
|
||||
feed_command('set mouse=a')
|
||||
|
||||
local screen = Screen.new(30, 5)
|
||||
screen:set_default_attr_ids({
|
||||
[0] = {bold = true, foreground = Screen.colors.Blue},
|
||||
})
|
||||
screen:attach()
|
||||
insert([[
|
||||
the source
|
||||
@@ -646,10 +658,10 @@ describe('clipboard (with fake clipboard.vim)', function()
|
||||
screen:expect([[
|
||||
the ^source |
|
||||
a target |
|
||||
~ |
|
||||
~ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]], nil, {{bold = true, foreground = Screen.colors.Blue}})
|
||||
]])
|
||||
|
||||
feed('<MiddleMouse><0,1>')
|
||||
expect([[
|
||||
|
@@ -208,18 +208,18 @@ describe(':terminal buffer', function()
|
||||
feed_command('terminal')
|
||||
feed('<c-\\><c-n>')
|
||||
feed_command('confirm bdelete')
|
||||
screen:expect{any='Close "term://', attr_ignore=true}
|
||||
screen:expect{any='Close "term://'}
|
||||
end)
|
||||
|
||||
it('with &confirm', function()
|
||||
feed_command('terminal')
|
||||
feed('<c-\\><c-n>')
|
||||
feed_command('bdelete')
|
||||
screen:expect{any='E89', attr_ignore=true}
|
||||
screen:expect{any='E89'}
|
||||
feed('<cr>')
|
||||
eq('terminal', eval('&buftype'))
|
||||
feed_command('set confirm | bdelete')
|
||||
screen:expect{any='Close "term://', attr_ignore=true}
|
||||
screen:expect{any='Close "term://'}
|
||||
feed('y')
|
||||
neq('terminal', eval('&buftype'))
|
||||
end)
|
||||
|
@@ -26,6 +26,8 @@ describe('ui/mouse/input', function()
|
||||
},
|
||||
[4] = {reverse = true},
|
||||
[5] = {bold = true, reverse = true},
|
||||
[6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
|
||||
[7] = {bold = true, foreground = Screen.colors.SeaGreen4},
|
||||
})
|
||||
command("set display-=msgsep")
|
||||
feed('itesting<cr>mouse<cr>support and selection<esc>')
|
||||
@@ -620,12 +622,12 @@ describe('ui/mouse/input', function()
|
||||
meths.set_option('tags', './non-existent-tags-file')
|
||||
feed('<C-LeftMouse><0,0>')
|
||||
screen:expect([[
|
||||
E433: No tags file |
|
||||
E426: tag not found: test|
|
||||
ing |
|
||||
Press ENTER or type comma|
|
||||
nd to continue^ |
|
||||
]],nil,true)
|
||||
{6:E433: No tags file} |
|
||||
{6:E426: tag not found: test}|
|
||||
{6:ing} |
|
||||
{7:Press ENTER or type comma}|
|
||||
{7:nd to continue}^ |
|
||||
]])
|
||||
feed('<cr>')
|
||||
end)
|
||||
|
||||
|
@@ -66,7 +66,6 @@
|
||||
-- [1] = {reverse = true, bold = true},
|
||||
-- [2] = {reverse = true}
|
||||
-- })
|
||||
-- screen:set_default_attr_ignore( {{}, {bold=true, foreground=NonText}} )
|
||||
--
|
||||
-- To help write screen tests, see Screen:snapshot_util().
|
||||
-- To debug screen tests, see Screen:redraw_debug().
|
||||
@@ -169,7 +168,6 @@ function Screen.new(width, height)
|
||||
ruler = {},
|
||||
hl_groups = {},
|
||||
_default_attr_ids = nil,
|
||||
_default_attr_ignore = nil,
|
||||
_mouse_enabled = true,
|
||||
_attrs = {},
|
||||
_hl_info = {[0]={}},
|
||||
@@ -202,10 +200,6 @@ function Screen:get_default_attr_ids()
|
||||
return deepcopy(self._default_attr_ids)
|
||||
end
|
||||
|
||||
function Screen:set_default_attr_ignore(attr_ignore)
|
||||
self._default_attr_ignore = attr_ignore
|
||||
end
|
||||
|
||||
function Screen:set_rgb_cterm(val)
|
||||
self._rgb_cterm = val
|
||||
end
|
||||
@@ -361,7 +355,7 @@ function Screen:expect(expected, attr_ids, attr_ignore, ...)
|
||||
end
|
||||
local attr_state = {
|
||||
ids = attr_ids or self._default_attr_ids,
|
||||
ignore = attr_ignore or self._default_attr_ignore,
|
||||
ignore = attr_ignore
|
||||
}
|
||||
if self._options.ext_linegrid then
|
||||
attr_state.id_to_index = self:linegrid_check_attrs(attr_state.ids or {})
|
||||
@@ -1478,6 +1472,8 @@ function Screen:_get_attr_id(attr_state, attrs, hl_id)
|
||||
return nil
|
||||
elseif id ~= nil then
|
||||
return id
|
||||
elseif attr_state.ignore == true then
|
||||
return nil
|
||||
end
|
||||
if attr_state.mutable then
|
||||
id = self:_insert_hl_id(attr_state, hl_id)
|
||||
|
Reference in New Issue
Block a user