From 1037ce2e461034a20e35ad59969fd05d5ad68b91 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 9 Dec 2023 20:42:00 +0800 Subject: test: avoid repeated screen lines in expected states This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g --- test/functional/ui/syntax_conceal_spec.lua | 464 +++++++---------------------- 1 file changed, 105 insertions(+), 359 deletions(-) (limited to 'test/functional/ui/syntax_conceal_spec.lua') diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua index 1391985823..c3406067bc 100644 --- a/test/functional/ui/syntax_conceal_spec.lua +++ b/test/functional/ui/syntax_conceal_spec.lua @@ -45,15 +45,9 @@ describe('Screen', function() it("double characters.", function() screen:expect([[ - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | + {1:∧} |*6 ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -61,15 +55,10 @@ describe('Screen', function() it('double characters and move the cursor one line up.', function() feed("k") screen:expect([[ - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | + {1:∧} |*5 ^&& | | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -78,14 +67,9 @@ describe('Screen', function() feed("gg") screen:expect([[ ^&& | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | + {1:∧} |*5 | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -95,13 +79,9 @@ describe('Screen', function() screen:expect([[ {1:∧} | ^&& | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | + {1:∧} |*4 | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -109,15 +89,9 @@ describe('Screen', function() it('double characters and then move the cursor to the beginning of the file and back to the end of the file.', function() feed("ggG") screen:expect([[ - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | + {1:∧} |*6 ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -128,15 +102,9 @@ describe('Screen', function() command("let &conceallevel=1") command("syn keyword kLambda lambda conceal cchar=λ") screen:expect([[ - {1:λ} | - {1:λ} | + {1:λ} |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 | ]]) end) -- Keyword @@ -152,15 +120,9 @@ describe('Screen', function() it('initially and conceal it.', function() command("syn region rText start='' end='' conceal cchar=R") screen:expect([[ - {1:R} | - {1:R} | + {1:R} |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 | ]]) end) @@ -170,15 +132,9 @@ describe('Screen', function() -- be replaced with cchar. command("syn region rText matchgroup=rMatch start='' end='' concealends cchar=-") screen:expect([[ - {1: } a region of text {1:-} | - {1: } a region of text {1:-} | + {1: } a region of text {1:-} |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 | ]]) end) @@ -187,15 +143,11 @@ describe('Screen', function() command("syn region rText contains=rText matchgroup=rMatch start='' end='' concealends cchar=-") insert(" A region with a nested nested region. \n") screen:expect([[ - {1: } a region of text {1:-} | - {1: } a region of text {1:-} | + {1: } a region of text {1:-} |*2 {1: } A region with {1: } a nested {1: } nested region.{1:-} | {1:-} {1:-} | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) @@ -211,15 +163,9 @@ describe('Screen', function() it("and turn on implicit concealing", function() screen:expect([[ - {1:-} | - {1:-} | + {1:-} |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 | ]]) end) @@ -230,29 +176,19 @@ describe('Screen', function() insert(" italian text \n") command("syn region iText start='' end='' cchar=*") screen:expect([[ - {1:-} | - {1:-} | - italian text | - italian text | + {1:-} |*2 + italian text |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) command("syntax conceal on") command("syn region iText start='' end='' cchar=*") screen:expect([[ - {1:-} | - {1:-} | - {1:*} | - {1:*} | + {1:-} |*2 + {1:*} |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) @@ -266,28 +202,14 @@ describe('Screen', function() command("syn match Foo /foobar/ conceal cchar=&") screen:expect([[ {1:&&&}^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 | ]]) feed("i") -- cursor should stay in place, not jump to column 16 screen:expect([[ {1:&&&}^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 {4:-- INSERT --} | ]]) end) @@ -311,10 +233,7 @@ describe('Screen', function() + With cchar | | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) @@ -327,10 +246,7 @@ describe('Screen', function() {1:C} | | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) @@ -343,10 +259,7 @@ describe('Screen', function() {1:C} | | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) @@ -355,14 +268,9 @@ describe('Screen', function() command("let &conceallevel=3") screen:expect([[ // No Conceal | - | - | - | + |*3 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) @@ -375,15 +283,10 @@ describe('Screen', function() command("set cole=2") feed('5Ofoo barf bar barf eggs') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 foo barf bar barf egg^s | | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) @@ -398,18 +301,14 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | | {2:[No Name] [+] }| - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*3 {3:[No Name] [+] }| | ]]) feed('w') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*3 | {3:[No Name] [+] }| foo {1:b} bar {1:b} eggs | @@ -423,29 +322,20 @@ describe('Screen', function() it('in insert mode', function() feed('i') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 foo barf bar barf egg^s | | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- INSERT --} | ]]) feed('') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*3 foo barf bar barf egg^s | foo {1:b} bar {1:b} eggs | | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- INSERT --} | ]]) end) @@ -455,70 +345,45 @@ describe('Screen', function() feed('gg') screen:expect([[ ^foo barf bar barf eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) feed('i') screen:expect([[ ^foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- INSERT --} | ]]) feed('') screen:expect([[ ^foo barf bar barf eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) feed('v') screen:expect([[ ^foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- VISUAL --} | ]]) feed('') screen:expect([[ ^foo barf bar barf eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) @@ -529,42 +394,27 @@ describe('Screen', function() feed('gg') screen:expect([[ ^foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) feed('i') screen:expect([[ ^foo barf bar barf eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- INSERT --} | ]]) feed('') screen:expect([[ ^foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) @@ -572,28 +422,18 @@ describe('Screen', function() feed('v') screen:expect([[ ^foo barf bar barf eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- VISUAL --} | ]]) feed('') screen:expect([[ ^foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) @@ -601,15 +441,10 @@ describe('Screen', function() it('and open line', function() feed('o') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*5 ^ | | - {0:~ }| - {0:~ }| + {0:~ }|*2 {4:-- INSERT --} | ]]) end) @@ -618,15 +453,10 @@ describe('Screen', function() command('set cocu=i') feed('o') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*5 ^ | | - {0:~ }| - {0:~ }| + {0:~ }|*2 {4:-- INSERT --} | ]]) end) @@ -639,12 +469,9 @@ describe('Screen', function() ^foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) @@ -655,12 +482,9 @@ describe('Screen', function() foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) @@ -669,12 +493,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo barf bar barf eggs {3:x} | foo {1:b} bar {1:b} eggs {5:x}y | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /x^ | ]]) @@ -683,12 +504,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo barf bar barf eggs {3:xy} | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /xy^ | ]]) @@ -697,12 +515,9 @@ describe('Screen', function() foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) end) @@ -717,12 +532,9 @@ describe('Screen', function() foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) @@ -731,12 +543,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs {3:x} | foo {1:b} bar {1:b} eggs {5:x}y | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /x^ | ]]) @@ -745,12 +554,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs {3:xy} | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /xy^ | ]]) @@ -759,12 +565,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) @@ -773,12 +576,9 @@ describe('Screen', function() ^foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) @@ -789,12 +589,9 @@ describe('Screen', function() ^foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) @@ -805,12 +602,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) @@ -819,12 +613,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo barf bar barf eggs {3:x} | foo {1:b} bar {1:b} eggs {5:x}y | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /x^ | ]]) @@ -833,12 +624,9 @@ describe('Screen', function() foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) @@ -847,12 +635,9 @@ describe('Screen', function() ^foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) @@ -865,40 +650,23 @@ describe('Screen', function() feed(':3o aggV') screen:expect{grid=[[ ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 a | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*5 {4:-- VISUAL LINE --} | ]]} feed(string.rep('j', 15)) screen:expect{grid=[[ - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | + {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |*8 ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} | {4:-- VISUAL LINE --} | ]]} feed(string.rep('k', 15)) screen:expect{grid=[[ ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 a | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*5 {4:-- VISUAL LINE --} | ]]} end) @@ -918,11 +686,7 @@ describe('Screen', function() bbb | ccc | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]} @@ -940,11 +704,7 @@ describe('Screen', function() bbb | ^ccc | | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]} eq({{2, 0, {{'c', 0, 3}, {' ', 0, 50}}}, {3, 0, {{' ', 0, 53}}}}, grid_lines) @@ -965,11 +725,7 @@ describe('Screen', function() bbb | ccc | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]} @@ -987,11 +743,7 @@ describe('Screen', function() bbb | ^ccc | | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]} eq({{2, 0, {{'c', 0, 3}, {' ', 0, 50}}}}, grid_lines) @@ -1067,13 +819,7 @@ describe('Screen', function() screen:expect{grid=[[ ^c | | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 | ]]} end) -- cgit From 04f2f864e270e772c6326cefdf24947f0130e492 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2024 02:09:18 +0100 Subject: refactor: format test/* --- test/functional/ui/syntax_conceal_spec.lua | 209 ++++++++++++++++------------- 1 file changed, 114 insertions(+), 95 deletions(-) (limited to 'test/functional/ui/syntax_conceal_spec.lua') diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua index c3406067bc..087fdf4f14 100644 --- a/test/functional/ui/syntax_conceal_spec.lua +++ b/test/functional/ui/syntax_conceal_spec.lua @@ -11,26 +11,25 @@ describe('Screen', function() before_each(function() clear() - screen = Screen.new(nil,10) + screen = Screen.new(nil, 10) screen:attach() - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray}, - [2] = {bold = true, reverse = true}, - [3] = {reverse = true}, - [4] = {bold = true}, - [5] = {background = Screen.colors.Yellow}, - [6] = {background = Screen.colors.LightGrey}, - } ) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }, + [2] = { bold = true, reverse = true }, + [3] = { reverse = true }, + [4] = { bold = true }, + [5] = { background = Screen.colors.Yellow }, + [6] = { background = Screen.colors.LightGrey }, + }) end) - describe("match and conceal", function() - + describe('match and conceal', function() before_each(function() - command("let &conceallevel=1") + command('let &conceallevel=1') end) - describe("multiple", function() + describe('multiple', function() before_each(function() insert([[ && @@ -43,7 +42,7 @@ describe('Screen', function() command("syn match dAmpersand '[&][&]' conceal cchar=∧") end) - it("double characters.", function() + it('double characters.', function() screen:expect([[ {1:∧} |*6 ^ | @@ -53,7 +52,7 @@ describe('Screen', function() end) it('double characters and move the cursor one line up.', function() - feed("k") + feed('k') screen:expect([[ {1:∧} |*5 ^&& | @@ -64,7 +63,7 @@ describe('Screen', function() end) it('double characters and move the cursor to the beginning of the file.', function() - feed("gg") + feed('gg') screen:expect([[ ^&& | {1:∧} |*5 @@ -75,7 +74,7 @@ describe('Screen', function() end) it('double characters and move the cursor to the second line in the file.', function() - feed("ggj") + feed('ggj') screen:expect([[ {1:∧} | ^&& | @@ -86,21 +85,24 @@ describe('Screen', function() ]]) end) - it('double characters and then move the cursor to the beginning of the file and back to the end of the file.', function() - feed("ggG") - screen:expect([[ + it( + 'double characters and then move the cursor to the beginning of the file and back to the end of the file.', + function() + feed('ggG') + screen:expect([[ {1:∧} |*6 ^ | {0:~ }|*2 | ]]) - end) + end + ) end) -- multiple - it("keyword instances in initially in the document.", function() - feed("2ilambda") - command("let &conceallevel=1") - command("syn keyword kLambda lambda conceal cchar=λ") + it('keyword instances in initially in the document.', function() + feed('2ilambda') + command('let &conceallevel=1') + command('syn keyword kLambda lambda conceal cchar=λ') screen:expect([[ {1:λ} |*2 ^ | @@ -109,12 +111,11 @@ describe('Screen', function() ]]) end) -- Keyword - describe("regions in the document", function() - + describe('regions in the document', function() before_each(function() - feed("2") - insert(" a region of text \n") - command("let &conceallevel=1") + feed('2') + insert(' a region of text \n') + command('let &conceallevel=1') end) it('initially and conceal it.', function() @@ -139,9 +140,11 @@ describe('Screen', function() ]]) end) - it('that are nested and conceal the nested region\'s start and end tags.', function() - command("syn region rText contains=rText matchgroup=rMatch start='' end='' concealends cchar=-") - insert(" A region with a nested nested region. \n") + it("that are nested and conceal the nested region's start and end tags.", function() + command( + "syn region rText contains=rText matchgroup=rMatch start='' end='' concealends cchar=-" + ) + insert(' A region with a nested nested region. \n') screen:expect([[ {1: } a region of text {1:-} |*2 {1: } A region with {1: } a nested {1: } nested region.{1:-} | @@ -153,15 +156,15 @@ describe('Screen', function() end) end) -- regions in the document - describe("a region of text", function() + describe('a region of text', function() before_each(function() - command("syntax conceal on") - feed("2") - insert(" a region of text \n") + command('syntax conceal on') + feed('2') + insert(' a region of text \n') command("syn region rText start='' end='' cchar=-") end) - it("and turn on implicit concealing", function() + it('and turn on implicit concealing', function() screen:expect([[ {1:-} |*2 ^ | @@ -170,10 +173,10 @@ describe('Screen', function() ]]) end) - it("and then turn on, then off, and then back on implicit concealing.", function() - command("syntax conceal off") - feed("2") - insert(" italian text \n") + it('and then turn on, then off, and then back on implicit concealing.', function() + command('syntax conceal off') + feed('2') + insert(' italian text \n') command("syn region iText start='' end='' cchar=*") screen:expect([[ {1:-} |*2 @@ -182,7 +185,7 @@ describe('Screen', function() {0:~ }|*4 | ]]) - command("syntax conceal on") + command('syntax conceal on') command("syn region iText start='' end='' cchar=*") screen:expect([[ {1:-} |*2 @@ -194,18 +197,18 @@ describe('Screen', function() end) end) -- a region of text (implicit concealing) - it("cursor position is correct when entering Insert mode with cocu=ni #13916", function() + it('cursor position is correct when entering Insert mode with cocu=ni #13916', function() insert([[foobarfoobarfoobar]]) -- move to end of line - feed("$") - command("set concealcursor=ni") - command("syn match Foo /foobar/ conceal cchar=&") + feed('$') + command('set concealcursor=ni') + command('syn match Foo /foobar/ conceal cchar=&') screen:expect([[ {1:&&&}^ | {0:~ }|*8 | ]]) - feed("i") + feed('i') -- cursor should stay in place, not jump to column 16 screen:expect([[ {1:&&&}^ | @@ -215,18 +218,18 @@ describe('Screen', function() end) end) -- match and conceal - describe("let the conceal level be", function() + describe('let the conceal level be', function() before_each(function() - insert("// No Conceal\n") + insert('// No Conceal\n') insert('"Conceal without a cchar"\n') - insert("+ With cchar\n\n") + insert('+ With cchar\n\n') command("syn match noConceal '^//.*$'") - command("syn match concealNoCchar '\".\\{-}\"$' conceal") + command('syn match concealNoCchar \'".\\{-}"$\' conceal') command("syn match concealWCchar '^+.\\{-}$' conceal cchar=C") end) - it("0. No concealing.", function() - command("let &conceallevel=0") + it('0. No concealing.', function() + command('let &conceallevel=0') screen:expect([[ // No Conceal | "Conceal without a cchar" | @@ -238,8 +241,8 @@ describe('Screen', function() ]]) end) - it("1. Conceal using cchar or reference listchars.", function() - command("let &conceallevel=1") + it('1. Conceal using cchar or reference listchars.', function() + command('let &conceallevel=1') screen:expect([[ // No Conceal | {1: } | @@ -251,8 +254,8 @@ describe('Screen', function() ]]) end) - it("2. Hidden unless cchar is set.", function() - command("let &conceallevel=2") + it('2. Hidden unless cchar is set.', function() + command('let &conceallevel=2') screen:expect([[ // No Conceal | | @@ -264,8 +267,8 @@ describe('Screen', function() ]]) end) - it("3. Hide all concealed text.", function() - command("let &conceallevel=3") + it('3. Hide all concealed text.', function() + command('let &conceallevel=3') screen:expect([[ // No Conceal | |*3 @@ -276,11 +279,10 @@ describe('Screen', function() end) end) -- conceallevel - - describe("cursor movement", function() + describe('cursor movement', function() before_each(function() - command("syn keyword concealy barf conceal cchar=b") - command("set cole=2") + command('syn keyword concealy barf conceal cchar=b') + command('set cole=2') feed('5Ofoo barf bar barf eggs') screen:expect([[ foo {1:b} bar {1:b} eggs |*4 @@ -289,12 +291,11 @@ describe('Screen', function() {0:~ }|*3 | ]]) - end) it('between windows', function() feed('k') - command("split") + command('split') screen:expect([[ foo {1:b} bar {1:b} eggs | foo barf bar barf egg^s | @@ -386,7 +387,6 @@ describe('Screen', function() {0:~ }|*3 | ]]) - end) it('between modes cocu=n', function() @@ -418,7 +418,6 @@ describe('Screen', function() | ]]) - feed('v') screen:expect([[ ^foo barf bar barf eggs | @@ -648,27 +647,33 @@ describe('Screen', function() feed('10Ofoo barf bar barf eggs') feed(':3o aggV') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} | foo {1:b} bar {1:b} eggs |*2 a | foo {1:b} bar {1:b} eggs |*5 {4:-- VISUAL LINE --} | - ]]} + ]], + } feed(string.rep('j', 15)) - screen:expect{grid=[[ + screen:expect { + grid = [[ {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |*8 ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} | {4:-- VISUAL LINE --} | - ]]} + ]], + } feed(string.rep('k', 15)) - screen:expect{grid=[[ + screen:expect { + grid = [[ ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} | foo {1:b} bar {1:b} eggs |*2 a | foo {1:b} bar {1:b} eggs |*5 {4:-- VISUAL LINE --} | - ]]} + ]], + } end) end) @@ -681,33 +686,37 @@ describe('Screen', function() bbb ccc ]]) - screen:expect{grid=[[ + screen:expect { + grid = [[ aaa | bbb | ccc | ^ | {0:~ }|*5 | - ]]} + ]], + } -- XXX: hack to get notifications, and check only a single line is -- updated. Could use next_msg() also. local orig_handle_grid_line = screen._handle_grid_line local grid_lines = {} function screen._handle_grid_line(self, grid, row, col, items) - table.insert(grid_lines, {row, col, items}) + table.insert(grid_lines, { row, col, items }) orig_handle_grid_line(self, grid, row, col, items) end feed('k') - screen:expect{grid=[[ + screen:expect { + grid = [[ aaa | bbb | ^ccc | | {0:~ }|*5 | - ]]} - eq({{2, 0, {{'c', 0, 3}, {' ', 0, 50}}}, {3, 0, {{' ', 0, 53}}}}, grid_lines) + ]], + } + eq({ { 2, 0, { { 'c', 0, 3 }, { ' ', 0, 50 } } }, { 3, 0, { { ' ', 0, 53 } } } }, grid_lines) end) it('K_EVENT should not cause extra redraws with concealcursor #13196', function() @@ -720,35 +729,39 @@ describe('Screen', function() bbb ccc ]]) - screen:expect{grid=[[ + screen:expect { + grid = [[ aaa | bbb | ccc | ^ | {0:~ }|*5 | - ]]} + ]], + } -- XXX: hack to get notifications, and check only a single line is -- updated. Could use next_msg() also. local orig_handle_grid_line = screen._handle_grid_line local grid_lines = {} function screen._handle_grid_line(self, grid, row, col, items) - table.insert(grid_lines, {row, col, items}) + table.insert(grid_lines, { row, col, items }) orig_handle_grid_line(self, grid, row, col, items) end feed('k') - screen:expect{grid=[[ + screen:expect { + grid = [[ aaa | bbb | ^ccc | | {0:~ }|*5 | - ]]} - eq({{2, 0, {{'c', 0, 3}, {' ', 0, 50}}}}, grid_lines) + ]], + } + eq({ { 2, 0, { { 'c', 0, 3 }, { ' ', 0, 50 } } } }, grid_lines) grid_lines = {} - poke_eventloop() -- causes K_EVENT key + poke_eventloop() -- causes K_EVENT key screen:expect_unchanged() eq({}, grid_lines) -- no redraw was done end) @@ -767,7 +780,8 @@ describe('Screen', function() command('set nomodified') command('so') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^3split | let m matchadd('Conceal', '') | setl conceallevel2 concealcursornc | @@ -778,16 +792,18 @@ describe('Screen', function() normal gg | {3:Xcolesearch }| | - ]]} + ]], + } -- Jump to something that is beyond the bottom of the window, -- so there's a scroll down. - feed("/expr") + feed('/expr') -- Are the concealed parts of the current line really hidden? -- Is the window's cursor column properly updated for hidden -- parts of the current line? - screen:expect{grid=[[ + screen:expect { + grid = [[ setl conceallevel2 concealcursornc | normal gg | "{5:^expr} | @@ -798,7 +814,8 @@ describe('Screen', function() normal gg | {3:Xcolesearch }| /expr | - ]]} + ]], + } end) -- oldtest: Test_cursor_column_in_concealed_line_after_leftcol_change() @@ -816,12 +833,14 @@ describe('Screen', function() -- Are the concealed parts of the current line really hidden? -- Is the window's cursor column properly updated for conceal? - screen:expect{grid=[[ + screen:expect { + grid = [[ ^c | | {0:~ }|*7 | - ]]} + ]], + } end) end) end) -- cgit From 31b3c62845fe7da41eed0089990e1540b9a41053 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 15 Feb 2024 07:49:39 +0800 Subject: vim-patch:9.1.0106: Visual highlight hard to read with 'termguicolors' Problem: Visual highlight hard to read with 'termguicolors' (Maxim Kim) Solution: Set Visual GUI foreground to black (with background=light) and lightgrey (with background=dark) (Maxim Kim) fixes: vim/vim#14024 closes: vim/vim#14025 https://github.com/vim/vim/commit/34e4a05d02a016fe230495be8f6c60ddd56f9567 Co-authored-by: Maxim Kim --- test/functional/ui/syntax_conceal_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/syntax_conceal_spec.lua') diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua index 087fdf4f14..5afc7dfe6c 100644 --- a/test/functional/ui/syntax_conceal_spec.lua +++ b/test/functional/ui/syntax_conceal_spec.lua @@ -20,7 +20,7 @@ describe('Screen', function() [3] = { reverse = true }, [4] = { bold = true }, [5] = { background = Screen.colors.Yellow }, - [6] = { background = Screen.colors.LightGrey }, + [6] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey }, }) end) -- cgit