fix(tests): use more global highlight definitions

This commit is contained in:
bfredl 2024-04-08 08:32:45 +02:00
parent c695caa7ee
commit 3d44340cea
4 changed files with 1158 additions and 1246 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -237,13 +237,6 @@ describe("'inccommand' for user commands", function()
before_each(function() before_each(function()
clear() clear()
screen = Screen.new(40, 17) screen = Screen.new(40, 17)
screen:set_default_attr_ids({
[1] = { background = Screen.colors.Yellow1 },
[2] = { foreground = Screen.colors.Blue1, bold = true },
[3] = { reverse = true },
[4] = { reverse = true, bold = true },
[5] = { foreground = Screen.colors.Blue },
})
screen:attach() screen:attach()
exec_lua(setup_replace_cmd) exec_lua(setup_replace_cmd)
command('set cmdwinheight=5') command('set cmdwinheight=5')
@ -263,16 +256,16 @@ describe("'inccommand' for user commands", function()
command('set inccommand=nosplit') command('set inccommand=nosplit')
feed(':Replace text cats') feed(':Replace text cats')
screen:expect([[ screen:expect([[
{1:cats} on line 1 | {10:cats} on line 1 |
more {1:cats} on line 2 | more {10:cats} on line 2 |
oh no, even more {1:cats} | oh no, even more {10:cats} |
will the {1:cats} ever stop | will the {10:cats} ever stop |
oh well | oh well |
did the {1:cats} stop | did the {10:cats} stop |
why won't it stop | why won't it stop |
make the {1:cats} stop | make the {10:cats} stop |
| |
{2:~ }|*7 {1:~ }|*7
:Replace text cats^ | :Replace text cats^ |
]]) ]])
end) end)
@ -281,22 +274,22 @@ describe("'inccommand' for user commands", function()
command('set inccommand=split') command('set inccommand=split')
feed(':Replace text cats') feed(':Replace text cats')
screen:expect([[ screen:expect([[
{1:cats} on line 1 | {10:cats} on line 1 |
more {1:cats} on line 2 | more {10:cats} on line 2 |
oh no, even more {1:cats} | oh no, even more {10:cats} |
will the {1:cats} ever stop | will the {10:cats} ever stop |
oh well | oh well |
did the {1:cats} stop | did the {10:cats} stop |
why won't it stop | why won't it stop |
make the {1:cats} stop | make the {10:cats} stop |
| |
{4:[No Name] [+] }| {3:[No Name] [+] }|
|1| {1:cats} on line 1 | |1| {10:cats} on line 1 |
|2| more {1:cats} on line 2 | |2| more {10:cats} on line 2 |
|3| oh no, even more {1:cats} | |3| oh no, even more {10:cats} |
|4| will the {1:cats} ever stop | |4| will the {10:cats} ever stop |
|6| did the {1:cats} stop | |6| did the {10:cats} stop |
{3:[Preview] }| {2:[Preview] }|
:Replace text cats^ | :Replace text cats^ |
]]) ]])
end) end)
@ -314,7 +307,7 @@ describe("'inccommand' for user commands", function()
why won't it stop | why won't it stop |
make the text stop | make the text stop |
^ | ^ |
{2:~ }|*7 {1:~ }|*7
| |
]]) ]])
end) end)
@ -332,7 +325,7 @@ describe("'inccommand' for user commands", function()
why won't it stop | why won't it stop |
make the cats stop | make the cats stop |
^ | ^ |
{2:~ }|*7 {1:~ }|*7
:Replace text cats | :Replace text cats |
]]) ]])
end) end)
@ -341,7 +334,7 @@ describe("'inccommand' for user commands", function()
command('set inccommand=split') command('set inccommand=split')
feed('gg:.Replace text cats') feed('gg:.Replace text cats')
screen:expect([[ screen:expect([[
{1:cats} on line 1 | {10:cats} on line 1 |
more text on line 2 | more text on line 2 |
oh no, even more text | oh no, even more text |
will the text ever stop | will the text ever stop |
@ -350,7 +343,7 @@ describe("'inccommand' for user commands", function()
why won't it stop | why won't it stop |
make the text stop | make the text stop |
| |
{2:~ }|*7 {1:~ }|*7
:.Replace text cats^ | :.Replace text cats^ |
]]) ]])
end) end)
@ -394,7 +387,7 @@ describe("'inccommand' for user commands", function()
]]) ]])
feed(':C') feed(':C')
screen:expect([[ screen:expect([[
{1: cats on line 1} | {10: cats on line 1} |
more cats on line 2 | more cats on line 2 |
oh no, even more cats | oh no, even more cats |
will the cats ever stop | will the cats ever stop |
@ -403,7 +396,7 @@ describe("'inccommand' for user commands", function()
why won't it stop | why won't it stop |
make the cats stop | make the cats stop |
| |
{2:~ }|*7 {1:~ }|*7
:C^ | :C^ |
]]) ]])
assert_alive() assert_alive()
@ -453,7 +446,7 @@ describe("'inccommand' for user commands", function()
why won't it stop | why won't it stop |
make the text stop | make the text stop |
a.a.a.a. | a.a.a.a. |
{2:~ }|*7 {1:~ }|*7
:Test a.a.a.a.^ | :Test a.a.a.a.^ |
]]) ]])
feed('<C-V><Esc>u') feed('<C-V><Esc>u')
@ -467,8 +460,8 @@ describe("'inccommand' for user commands", function()
why won't it stop | why won't it stop |
make the text stop | make the text stop |
a.a.a. | a.a.a. |
{2:~ }|*7 {1:~ }|*7
:Test a.a.a.a.{5:^[}u^ | :Test a.a.a.a.{18:^[}u^ |
]]) ]])
feed('<Esc>') feed('<Esc>')
screen:expect([[ screen:expect([[
@ -481,7 +474,7 @@ describe("'inccommand' for user commands", function()
why won't it stop | why won't it stop |
make the text stop | make the text stop |
^ | ^ |
{2:~ }|*7 {1:~ }|*7
| |
]]) ]])
end end
@ -521,12 +514,6 @@ describe("'inccommand' with multiple buffers", function()
before_each(function() before_each(function()
clear() clear()
screen = Screen.new(40, 17) screen = Screen.new(40, 17)
screen:set_default_attr_ids({
[1] = { background = Screen.colors.Yellow1 },
[2] = { foreground = Screen.colors.Blue1, bold = true },
[3] = { reverse = true },
[4] = { reverse = true, bold = true },
})
screen:attach() screen:attach()
exec_lua(setup_replace_cmd) exec_lua(setup_replace_cmd)
command('set cmdwinheight=10') command('set cmdwinheight=10')
@ -547,12 +534,12 @@ describe("'inccommand' with multiple buffers", function()
command('set inccommand=nosplit') command('set inccommand=nosplit')
feed(':Replace foo bar') feed(':Replace foo bar')
screen:expect([[ screen:expect([[
bar baz {1:bar} {1:bar} bar baz | bar baz {10:bar} {10:bar} bar baz |
baz {1:bar} bar bar baz {1:bar} | baz {10:bar} bar bar baz {10:bar} |
{1:bar} bar baz baz {1:bar} bar | {10:bar} bar baz baz {10:bar} bar |
| |
{2:~ }{2:~ }|*11 {1:~ }{1:~ }|*11
{4:[No Name] [+] }{3:[No Name] [+] }| {3:[No Name] [+] }{2:[No Name] [+] }|
:Replace foo bar^ | :Replace foo bar^ |
]]) ]])
feed('<CR>') feed('<CR>')
@ -561,8 +548,8 @@ describe("'inccommand' with multiple buffers", function()
baz bar bar bar baz bar | baz bar bar bar baz bar |
bar bar baz baz bar bar | bar bar baz baz bar bar |
^ | ^ |
{2:~ }{2:~ }|*11 {1:~ }{1:~ }|*11
{4:[No Name] [+] }{3:[No Name] [+] }| {3:[No Name] [+] }{2:[No Name] [+] }|
:Replace foo bar | :Replace foo bar |
]]) ]])
end) end)
@ -571,22 +558,22 @@ describe("'inccommand' with multiple buffers", function()
command('set inccommand=split') command('set inccommand=split')
feed(':Replace foo bar') feed(':Replace foo bar')
screen:expect([[ screen:expect([[
bar baz {1:bar} {1:bar} bar baz | bar baz {10:bar} {10:bar} bar baz |
baz {1:bar} bar bar baz {1:bar} | baz {10:bar} bar bar baz {10:bar} |
{1:bar} bar baz baz {1:bar} bar | {10:bar} bar baz baz {10:bar} bar |
| |
{4:[No Name] [+] }{3:[No Name] [+] }| {3:[No Name] [+] }{2:[No Name] [+] }|
Buffer #1: | Buffer #1: |
|1| {1:bar} bar baz | |1| {10:bar} bar baz |
|2| bar baz {1:bar} | |2| bar baz {10:bar} |
|3| baz {1:bar} bar | |3| baz {10:bar} bar |
Buffer #2: | Buffer #2: |
|1| bar baz {1:bar} | |1| bar baz {10:bar} |
|2| baz {1:bar} bar | |2| baz {10:bar} bar |
|3| {1:bar} bar baz | |3| {10:bar} bar baz |
| |
{2:~ }| {1:~ }|
{3:[Preview] }| {2:[Preview] }|
:Replace foo bar^ | :Replace foo bar^ |
]]) ]])
feed('<CR>') feed('<CR>')
@ -595,8 +582,8 @@ describe("'inccommand' with multiple buffers", function()
baz bar bar bar baz bar | baz bar bar bar baz bar |
bar bar baz baz bar bar | bar bar baz baz bar bar |
^ | ^ |
{2:~ }{2:~ }|*11 {1:~ }{1:~ }|*11
{4:[No Name] [+] }{3:[No Name] [+] }| {3:[No Name] [+] }{2:[No Name] [+] }|
:Replace foo bar | :Replace foo bar |
]]) ]])
end) end)

View File

@ -108,20 +108,15 @@ describe('shell command :!', function()
it('handles control codes', function() it('handles control codes', function()
skip(is_os('win'), 'missing printf') skip(is_os('win'), 'missing printf')
local screen = Screen.new(50, 4) local screen = Screen.new(50, 4)
screen:set_default_attr_ids {
[1] = { bold = true, reverse = true },
[2] = { bold = true, foreground = Screen.colors.SeaGreen },
[3] = { foreground = Screen.colors.Blue },
}
screen:attach() screen:attach()
-- Print TAB chars. #2958 -- Print TAB chars. #2958
feed([[:!printf '1\t2\t3'<CR>]]) feed([[:!printf '1\t2\t3'<CR>]])
screen:expect { screen:expect {
grid = [[ grid = [[
{1: }| {3: }|
:!printf '1\t2\t3' | :!printf '1\t2\t3' |
1 2 3 | 1 2 3 |
{2:Press ENTER or type command to continue}^ | {6:Press ENTER or type command to continue}^ |
]], ]],
} }
feed([[<CR>]]) feed([[<CR>]])
@ -131,10 +126,10 @@ describe('shell command :!', function()
feed([[:!printf '\007\007\007\007text'<CR>]]) feed([[:!printf '\007\007\007\007text'<CR>]])
screen:expect { screen:expect {
grid = [[ grid = [[
{1: }| {3: }|
:!printf '\007\007\007\007text' | :!printf '\007\007\007\007text' |
text | text |
{2:Press ENTER or type command to continue}^ | {6:Press ENTER or type command to continue}^ |
]], ]],
condition = function() condition = function()
eq(true, screen.bell) eq(true, screen.bell)
@ -145,10 +140,10 @@ describe('shell command :!', function()
-- Print BS control code. -- Print BS control code.
feed([[:echo system('printf ''\010\n''')<CR>]]) feed([[:echo system('printf ''\010\n''')<CR>]])
screen:expect([[ screen:expect([[
{1: }| {3: }|
{3:^H} | {18:^H} |
| |
{2:Press ENTER or type command to continue}^ | {6:Press ENTER or type command to continue}^ |
]]) ]])
feed([[<CR>]]) feed([[<CR>]])
@ -157,7 +152,7 @@ describe('shell command :!', function()
screen:expect([[ screen:expect([[
:!printf '\n' | :!printf '\n' |
|*2 |*2
{2:Press ENTER or type command to continue}^ | {6:Press ENTER or type command to continue}^ |
]]) ]])
feed([[<CR>]]) feed([[<CR>]])
end) end)
@ -171,12 +166,6 @@ describe('shell command :!', function()
write_file('bang_filter_spec/f2', 'f2') write_file('bang_filter_spec/f2', 'f2')
write_file('bang_filter_spec/f3', 'f3') write_file('bang_filter_spec/f3', 'f3')
screen = Screen.new(53, 10) screen = Screen.new(53, 10)
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue1 },
[2] = { foreground = Screen.colors.Blue1 },
[3] = { bold = true, foreground = Screen.colors.SeaGreen4 },
[4] = { bold = true, reverse = true },
})
screen:attach() screen:attach()
end) end)
@ -196,13 +185,13 @@ describe('shell command :!', function()
screen:expect([[ screen:expect([[
| |
{1:~ }|*2 {1:~ }|*2
{4: }| {3: }|
]] .. result .. [[ | ]] .. result .. [[ |
f1 | f1 |
f2 | f2 |
f3 | f3 |
| |
{3:Press ENTER or type command to continue}^ | {6:Press ENTER or type command to continue}^ |
]]) ]])
end) end)
@ -213,14 +202,14 @@ describe('shell command :!', function()
grid = [[ grid = [[
| |
{1:~ }| {1:~ }|
{4: }| {3: }|
:!cat test/functional/fixtures/shell_data.txt | :!cat test/functional/fixtures/shell_data.txt |
{2:^@^A^B^C^D^E^F^H} | {18:^@^A^B^C^D^E^F^H} |
{2:^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_} | {18:^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_} |
ö {2:<a5><c3>} | ö {18:<a5><c3>} |
t {2:<ff>} | t {18:<ff>} |
| |
{3:Press ENTER or type command to continue}^ | {6:Press ENTER or type command to continue}^ |
]], ]],
condition = function() condition = function()
eq(true, screen.bell) eq(true, screen.bell)
@ -235,7 +224,7 @@ describe('shell command :!', function()
-- Note: only the first example of split composed char works -- Note: only the first example of split composed char works
screen:expect([[ screen:expect([[
| |
{4: }| {3: }|
:]] .. cmd .. [[ | :]] .. cmd .. [[ |
å | å |
ref: å̲ | ref: å̲ |
@ -243,7 +232,7 @@ describe('shell command :!', function()
2: å ̲ | 2: å ̲ |
3: å ̲ | 3: å ̲ |
| |
{3:Press ENTER or type command to continue}^ | {6:Press ENTER or type command to continue}^ |
]]) ]])
end) end)
end) end)