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/cmdline_spec.lua | 408 +++++++++--------------------------- 1 file changed, 99 insertions(+), 309 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 188b9ee87b..cac070406d 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -41,9 +41,7 @@ local function test_cmdline(linegrid) feed(':') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -54,9 +52,7 @@ local function test_cmdline(linegrid) feed('sign') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -67,9 +63,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -80,9 +74,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -93,9 +85,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} end) @@ -104,9 +94,7 @@ local function test_cmdline(linegrid) feed(':call input("input", "default")') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ prompt = "input", @@ -117,9 +105,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} end) @@ -128,9 +114,7 @@ local function test_cmdline(linegrid) feed(':xx') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -142,9 +126,7 @@ local function test_cmdline(linegrid) feed('=') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -171,9 +153,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline=expectation} @@ -181,9 +161,7 @@ local function test_cmdline(linegrid) command("mode") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline=expectation, reset=true} @@ -191,9 +169,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -204,9 +180,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} end) @@ -215,9 +189,7 @@ local function test_cmdline(linegrid) feed(':function Foo()') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ indent = 2, @@ -231,9 +203,7 @@ local function test_cmdline(linegrid) feed('line1') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ indent = 2, @@ -248,9 +218,7 @@ local function test_cmdline(linegrid) command("mode") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ indent = 2, @@ -265,9 +233,7 @@ local function test_cmdline(linegrid) feed('endfunction') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} @@ -275,9 +241,7 @@ local function test_cmdline(linegrid) feed(':function Bar()') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ indent = 2, @@ -291,9 +255,7 @@ local function test_cmdline(linegrid) feed('endfunction') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} @@ -303,9 +265,7 @@ local function test_cmdline(linegrid) feed(':make') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -374,9 +334,7 @@ local function test_cmdline(linegrid) command("redraw!") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -389,9 +347,7 @@ local function test_cmdline(linegrid) feed(":call inputsecret('secret:')abc123") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ prompt = "secret:", @@ -434,9 +390,7 @@ local function test_cmdline(linegrid) feed('(a(b)a)') screen:expect{grid=[[ ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*3 | ]], cmdline={{ prompt = '>', @@ -463,9 +417,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -476,9 +428,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -489,9 +439,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -502,9 +450,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -515,9 +461,7 @@ local function test_cmdline(linegrid) feed('a') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -543,9 +487,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -556,9 +498,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -569,9 +509,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -582,9 +520,7 @@ local function test_cmdline(linegrid) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -595,9 +531,7 @@ local function test_cmdline(linegrid) feed('a') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -645,9 +579,7 @@ local function test_cmdline(linegrid) screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ firstc = ":", @@ -663,9 +595,7 @@ local function test_cmdline(linegrid) feed(':xa') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]], cmdline={{ content = { { "x" } }, @@ -679,9 +609,7 @@ local function test_cmdline(linegrid) feed('') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end) @@ -748,26 +676,20 @@ describe('cmdline redraw', function() feed('q:iabcvhh') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] }| {1::}^a{8:bc} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:[Command Line] }| {9:-- VISUAL --} | ]]) feed('') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] }| {1::}a{8:bc} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:[Command Line] }| :^abc | ]]) @@ -778,18 +700,14 @@ describe('cmdline redraw', function() meths.buf_set_lines(0, 0, -1, true, {"let's rock!"}) screen:expect{grid=[[ !kcor s'te^l| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 | ]]} feed '/' screen:expect{grid=[[ !kcor s'tel| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^ /| ]]} @@ -798,9 +716,7 @@ describe('cmdline redraw', function() -- when rendered as a block so it touches the end of the text screen:expect{grid=[[ !kcor {2:s'tel}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^ s'tel/| ]]} @@ -808,45 +724,35 @@ describe('cmdline redraw', function() feed "" screen:expect{grid=[[ !kcor{2: s'tel}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^ s'tel/| ]]} feed "rock" screen:expect{grid=[[ !{2:kcor s'tel}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^ kcor s'tel/| ]]} feed "" screen:expect{grid=[[ !{2:kcor s'tel}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^kcor s'tel/| ]]} feed "" screen:expect{grid=[[ !{2:kcor s'tel}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^ kcor s'tel/| ]]} feed "" screen:expect{grid=[[ !{10:kcor s'te^l}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 kcor s'tel/ | ]]} end) @@ -865,8 +771,7 @@ describe('statusline is redrawn on entering cmdline', function() command('set statusline=%{mode()}') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:n }| | ]]} @@ -874,8 +779,7 @@ describe('statusline is redrawn on entering cmdline', function() feed(':') screen:expect{grid=[[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:c }| :^ | ]]} @@ -887,8 +791,7 @@ describe('statusline is redrawn on entering cmdline', function() screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:n }| | ]]} @@ -896,8 +799,7 @@ describe('statusline is redrawn on entering cmdline', function() feed(';') screen:expect{grid=[[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:c }| :^ | ]]} @@ -919,11 +821,7 @@ describe('statusline is redrawn on entering cmdline', function() | {3:c1 }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {3: }| {4:E121: Undefined variable: doesnotex}| {4:ist} | @@ -936,8 +834,7 @@ describe('statusline is redrawn on entering cmdline', function() | {3:c2 }| | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3: }| {4:E121: Undefined variable: doesnotex}| {4:ist} | @@ -972,14 +869,7 @@ describe('statusline is redrawn on entering cmdline', function() ^ | {3:n3 }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 {2:[No Name] }| | ]]} @@ -990,8 +880,7 @@ describe('statusline is redrawn on entering cmdline', function() command('set statusline=') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:[No Name] }| | ]]} @@ -1002,8 +891,7 @@ describe('statusline is redrawn on entering cmdline', function() feed(':') screen:expect{grid=[[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:command }| :^ | ]]} @@ -1014,8 +902,7 @@ describe('statusline is redrawn on entering cmdline', function() feed(':') screen:expect{grid=[[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:command }| :^ | ]]} @@ -1104,17 +991,12 @@ describe('cmdheight=0', function() command("set redrawdebug=invalid cmdheight=0 noruler laststatus=0") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} feed(":resize -1") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} assert_alive() @@ -1124,8 +1006,7 @@ describe('cmdheight=0', function() command("set cmdheight=1 noruler laststatus=2") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] }| | ]]} @@ -1135,9 +1016,7 @@ describe('cmdheight=0', function() command("set cmdheight=0 noruler laststatus=2") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] }| ]]} end) @@ -1146,10 +1025,7 @@ describe('cmdheight=0', function() command("set cmdheight=0 ruler laststatus=0") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} end) @@ -1158,10 +1034,7 @@ describe('cmdheight=0', function() feed('i') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={}} feed('') eq(0, eval('&cmdheight')) @@ -1172,10 +1045,7 @@ describe('cmdheight=0', function() feed('i') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={}} feed('') eq(0, eval('&cmdheight')) @@ -1186,9 +1056,7 @@ describe('cmdheight=0', function() feed('i') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {3:-- INSERT --} | ]]} feed('') @@ -1200,19 +1068,14 @@ describe('cmdheight=0', function() feed(':') screen:expect{grid=[[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :^ | ]]} eq(0, eval('&cmdheight')) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={}} eq(0, eval('&cmdheight')) end) @@ -1231,10 +1094,7 @@ describe('cmdheight=0', function() feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={}} eq(0, eval('&cmdheight')) end) @@ -1253,24 +1113,21 @@ describe('cmdheight=0', function() screen:expect{grid=[[ {3:foo }| ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] }| ]]} feed(':') screen:expect{grid=[[ {3:foo }| | - {1:~ }| - {1:~ }| + {1:~ }|*2 :^ | ]]} feed('') screen:expect{grid=[[ {3:foo }| ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] }| ]], showmode={}} eq(0, eval('&cmdheight')) @@ -1283,18 +1140,12 @@ describe('cmdheight=0', function() feed('qq') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} feed('q') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], unchanged=true} end) @@ -1303,27 +1154,21 @@ describe('cmdheight=0', function() feed('ifoo') screen:expect{grid=[[ fo^o | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] [+] }| ]]} feed(':%s/foo/bar/gc') screen:expect{grid=[[ {6:foo} | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {5:replace wi...q/l/^E/^Y)?}^ | ]]} feed('y') screen:expect{grid=[[ ^bar | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] [+] }| ]]} @@ -1342,19 +1187,13 @@ describe('cmdheight=0', function() feed('iaabbaa/aa') screen:expect{grid=[[ {7:^aa}bb{7:aa} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} feed('') screen:expect{grid=[[ ^aabbaa | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} end) @@ -1364,10 +1203,7 @@ describe('cmdheight=0', function() -- doesn't crash while not displaying silent! error message screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} end) @@ -1377,17 +1213,10 @@ describe('cmdheight=0', function() meths.buf_set_lines(0, 0, -1, true, {'p'}) screen:expect{grid=[[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*5 ## grid 2 ^p | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 ]], win_viewport={ [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; @@ -1396,17 +1225,11 @@ describe('cmdheight=0', function() feed '/p' screen:expect{grid=[[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*4 [3:-------------------------]| ## grid 2 {6:p} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 /p^ | ]], win_viewport={ @@ -1423,8 +1246,7 @@ describe('cmdheight=0', function() screen:expect([[ {3:c :}| | - {1:~ }| - {1:~ }| + {1:~ }|*2 :^ | ]]) feed('echo') @@ -1432,16 +1254,14 @@ describe('cmdheight=0', function() screen:expect([[ {3:c :}| | - {1:~ }| - {1:~ }| + {1:~ }|*2 :echo^ | ]]) command('redrawstatus') screen:expect([[ {3:c :echo}| | - {1:~ }| - {1:~ }| + {1:~ }|*2 :echo^ | ]]) end) @@ -1452,28 +1272,17 @@ describe('cmdheight=0', function() command('vsplit') screen:expect([[ ^ │ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*8 ]]) feed(':') command('split') feed('') screen:expect([[ ^ │ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 {2:[No Name] }│{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 ]]) command('resize 2') screen:expect([[ @@ -1481,25 +1290,17 @@ describe('cmdheight=0', function() {1:~ }│{1:~ }| {2:[No Name] }│{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*5 ]]) feed(':') command('wincmd =') feed('') screen:expect([[ ^ │ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 {2:[No Name] }│{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 ]]) end) @@ -1508,10 +1309,7 @@ describe('cmdheight=0', function() feed('d') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]) assert_alive() end) @@ -1521,33 +1319,27 @@ describe('cmdheight=0', function() command('resize +1') screen:expect([[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] }| | ]]) command('set cmdheight=0') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] }| ]]} command('resize -1') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] }| | ]]} command('resize +1') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] }| ]]) end) @@ -1559,9 +1351,7 @@ describe('cmdheight=0', function() command('resize -1') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {3:[No Name] }| ]]) meths.input_mouse('left', 'press', '', 0, 6, 10) -- 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/cmdline_spec.lua | 1257 ++++++++++++++++++++++------------- 1 file changed, 802 insertions(+), 455 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index cac070406d..82ff633fcb 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -15,16 +15,16 @@ local function new_screen(opt) local screen = Screen.new(25, 5) screen:attach(opt) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {reverse = true}, - [3] = {bold = true, reverse = true}, - [4] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [5] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [6] = {foreground = Screen.colors.Magenta}, - [7] = {bold = true, foreground = Screen.colors.Brown}, - [8] = {background = Screen.colors.LightGrey}, - [9] = {bold = true}, - [10] = {background = Screen.colors.Yellow1}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { reverse = true }, + [3] = { bold = true, reverse = true }, + [4] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [5] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [6] = { foreground = Screen.colors.Magenta }, + [7] = { bold = true, foreground = Screen.colors.Brown }, + [8] = { background = Screen.colors.LightGrey }, + [9] = { bold = true }, + [10] = { background = Screen.colors.Yellow1 }, }) return screen end @@ -34,326 +34,445 @@ local function test_cmdline(linegrid) before_each(function() clear() - screen = new_screen({rgb=true, ext_cmdline=true, ext_linegrid=linegrid}) + screen = new_screen({ rgb = true, ext_cmdline = true, ext_linegrid = linegrid }) end) it('works', function() feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{""}}, - pos = 0, - }}} + ]], + cmdline = { { + firstc = ':', + content = { { '' } }, + pos = 0, + } }, + } feed('sign') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign"}}, - pos = 4, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign' } }, + pos = 4, + }, + }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign"}}, - pos = 3, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign' } }, + pos = 3, + }, + }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sin"}}, - pos = 2, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sin' } }, + pos = 2, + }, + }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]]} + ]], + } end) - it("works with input()", function() + it('works with input()', function() feed(':call input("input", "default")') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - prompt = "input", - content = {{"default"}}, - pos = 7, - }}} + ]], + cmdline = { + { + prompt = 'input', + content = { { 'default' } }, + pos = 7, + }, + }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]]} + ]], + } end) - it("works with special chars and nested cmdline", function() + it('works with special chars and nested cmdline', function() feed(':xx') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"xx"}}, - pos = 2, - special = {'"', true}, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'xx' } }, + pos = 2, + special = { '"', true }, + }, + }, + } feed('=') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"xx"}}, - pos = 2, - special = {'"', true}, - }, { - firstc = "=", - content = {{""}}, - pos = 0, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'xx' } }, + pos = 2, + special = { '"', true }, + }, + { + firstc = '=', + content = { { '' } }, + pos = 0, + }, + }, + } feed('1+2') - local expectation = {{ - firstc = ":", - content = {{"xx"}}, - pos = 2, - special = {'"', true}, - }, { - firstc = "=", - content = {{"1", 6}, {"+", 7}, {"2", 6}}, - pos = 3, - }} - - screen:expect{grid=[[ + local expectation = { + { + firstc = ':', + content = { { 'xx' } }, + pos = 2, + special = { '"', true }, + }, + { + firstc = '=', + content = { { '1', 6 }, { '+', 7 }, { '2', 6 } }, + pos = 3, + }, + } + + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline=expectation} + ]], + cmdline = expectation, + } -- erase information, so we check if it is retransmitted - command("mode") - screen:expect{grid=[[ + command('mode') + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline=expectation, reset=true} - + ]], + cmdline = expectation, + reset = true, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"xx3"}}, - pos = 3, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'xx3' } }, + pos = 3, + }, + }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]]} + ]], + } end) - it("works with function definitions", function() + it('works with function definitions', function() feed(':function Foo()') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - indent = 2, - firstc = ":", - content = {{""}}, - pos = 0, - }}, cmdline_block = { - {{'function Foo()'}}, - }} + ]], + cmdline = { + { + indent = 2, + firstc = ':', + content = { { '' } }, + pos = 0, + }, + }, + cmdline_block = { + { { 'function Foo()' } }, + }, + } feed('line1') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - indent = 2, - firstc = ":", - content = {{""}}, - pos = 0, - }}, cmdline_block = { - {{'function Foo()'}}, - {{' line1'}}, - }} - - command("mode") - screen:expect{grid=[[ + ]], + cmdline = { + { + indent = 2, + firstc = ':', + content = { { '' } }, + pos = 0, + }, + }, + cmdline_block = { + { { 'function Foo()' } }, + { { ' line1' } }, + }, + } + + command('mode') + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - indent = 2, - firstc = ":", - content = {{""}}, - pos = 0, - }}, cmdline_block = { - {{'function Foo()'}}, - {{' line1'}}, - }, reset=true} + ]], + cmdline = { + { + indent = 2, + firstc = ':', + content = { { '' } }, + pos = 0, + }, + }, + cmdline_block = { + { { 'function Foo()' } }, + { { ' line1' } }, + }, + reset = true, + } feed('endfunction') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]]} + ]], + } -- Try once more, to check buffer is reinitialized. #8007 feed(':function Bar()') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - indent = 2, - firstc = ":", - content = {{""}}, - pos = 0, - }}, cmdline_block = { - {{'function Bar()'}}, - }} + ]], + cmdline = { + { + indent = 2, + firstc = ':', + content = { { '' } }, + pos = 0, + }, + }, + cmdline_block = { + { { 'function Bar()' } }, + }, + } feed('endfunction') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]]} - + ]], + } end) - it("works with cmdline window", function() + it('works with cmdline window', function() feed(':make') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"make"}}, - pos = 4, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'make' } }, + pos = 4, + }, + }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {2:[No Name] }| {1::}mak^e | {3:[Command Line] }| | - ]]} + ]], + } -- nested cmdline feed(':yank') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {2:[No Name] }| {1::}mak^e | {3:[Command Line] }| | - ]], cmdline={nil, { - firstc = ":", - content = {{"yank"}}, - pos = 4, - }}} - - command("mode") - screen:expect{grid=[[ + ]], + cmdline = { + nil, + { + firstc = ':', + content = { { 'yank' } }, + pos = 4, + }, + }, + } + + command('mode') + screen:expect { + grid = [[ | {2:[No Name] }| {1::}mak^e | {3:[Command Line] }| | - ]], cmdline={nil, { - firstc = ":", - content = {{"yank"}}, - pos = 4, - }}, reset=true} - - feed("") - screen:expect{grid=[[ + ]], + cmdline = { + nil, + { + firstc = ':', + content = { { 'yank' } }, + pos = 4, + }, + }, + reset = true, + } + + feed('') + screen:expect { + grid = [[ | {2:[No Name] }| {1::}mak^e | {3:[Command Line] }| | - ]]} + ]], + } - feed("") - screen:expect{grid=[[ + feed('') + screen:expect { + grid = [[ ^ | {2:[No Name] }| {1::}make | {3:[Command Line] }| | - ]], cmdline={{ - firstc = ":", - content = {{"make"}}, - pos = 4, - }}} - - command("redraw!") - screen:expect{grid=[[ + ]], + cmdline = { + { + firstc = ':', + content = { { 'make' } }, + pos = 4, + }, + }, + } + + command('redraw!') + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"make"}}, - pos = 4, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'make' } }, + pos = 4, + }, + }, + } end) it('works with inputsecret()', function() feed(":call inputsecret('secret:')abc123") - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - prompt = "secret:", - content = {{"******"}}, - pos = 6, - }}} + ]], + cmdline = { + { + prompt = 'secret:', + content = { { '******' } }, + pos = 6, + }, + }, + } end) it('works with highlighted cmdline', function() @@ -383,21 +502,33 @@ local function test_cmdline(linegrid) "map :let x = input({'prompt':'>'}) ]]) screen:set_default_attr_ids({ - RBP1={background = Screen.colors.Red}, - RBP2={background = Screen.colors.Yellow}, - EOB={bold = true, foreground = Screen.colors.Blue1}, + RBP1 = { background = Screen.colors.Red }, + RBP2 = { background = Screen.colors.Yellow }, + EOB = { bold = true, foreground = Screen.colors.Blue1 }, }) feed('(a(b)a)') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {EOB:~ }|*3 | - ]], cmdline={{ - prompt = '>', - content = {{'(', 'RBP1'}, {'a'}, {'(', 'RBP2'}, {'b'}, - { ')', 'RBP2'}, {'a'}, {')', 'RBP1'}}, - pos = 7, - }}} + ]], + cmdline = { + { + prompt = '>', + content = { + { '(', 'RBP1' }, + { 'a' }, + { '(', 'RBP2' }, + { 'b' }, + { ')', 'RBP2' }, + { 'a' }, + { ')', 'RBP1' }, + }, + pos = 7, + }, + }, + } end) it('works together with ext_wildmenu', function() @@ -415,69 +546,102 @@ local function test_cmdline(linegrid) screen:set_option('ext_wildmenu', true) feed(':sign ') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign define"}}, - pos = 11, - }}, wildmenu_items=expected, wildmenu_pos=0} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign define' } }, + pos = 11, + }, + }, + wildmenu_items = expected, + wildmenu_pos = 0, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign jump"}}, - pos = 9, - }}, wildmenu_items=expected, wildmenu_pos=1} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign jump' } }, + pos = 9, + }, + }, + wildmenu_items = expected, + wildmenu_pos = 1, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign "}}, - pos = 5, - }}, wildmenu_items=expected, wildmenu_pos=-1} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign ' } }, + pos = 5, + }, + }, + wildmenu_items = expected, + wildmenu_pos = -1, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign define"}}, - pos = 11, - }}, wildmenu_items=expected, wildmenu_pos=0} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign define' } }, + pos = 11, + }, + }, + wildmenu_items = expected, + wildmenu_pos = 0, + } feed('a') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign definea"}}, - pos = 12, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign definea' } }, + pos = 12, + }, + }, + } end) it('works together with ext_popupmenu', function() local expected = { - {'define', '', '', ''}, - {'jump', '', '', ''}, - {'list', '', '', ''}, - {'place', '', '', ''}, - {'undefine', '', '', ''}, - {'unplace', '', '', ''}, + { 'define', '', '', '' }, + { 'jump', '', '', '' }, + { 'list', '', '', '' }, + { 'place', '', '', '' }, + { 'undefine', '', '', '' }, + { 'unplace', '', '', '' }, } command('set wildmode=full') @@ -485,80 +649,115 @@ local function test_cmdline(linegrid) screen:set_option('ext_popupmenu', true) feed(':sign ') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign define"}}, - pos = 11, - }}, popupmenu={items=expected, pos=0, anchor={-1, 0, 5}}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign define' } }, + pos = 11, + }, + }, + popupmenu = { items = expected, pos = 0, anchor = { -1, 0, 5 } }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign jump"}}, - pos = 9, - }}, popupmenu={items=expected, pos=1, anchor={-1, 0, 5}}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign jump' } }, + pos = 9, + }, + }, + popupmenu = { items = expected, pos = 1, anchor = { -1, 0, 5 } }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign "}}, - pos = 5, - }}, popupmenu={items=expected, pos=-1, anchor={-1, 0, 5}}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign ' } }, + pos = 5, + }, + }, + popupmenu = { items = expected, pos = -1, anchor = { -1, 0, 5 } }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign define"}}, - pos = 11, - }}, popupmenu={items=expected, pos=0, anchor={-1, 0, 5}}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign define' } }, + pos = 11, + }, + }, + popupmenu = { items = expected, pos = 0, anchor = { -1, 0, 5 } }, + } feed('a') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign definea"}}, - pos = 12, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign definea' } }, + pos = 12, + }, + }, + } feed('') -- check positioning with multibyte char in pattern - command("e långfile1") - command("sp långfile2") + command('e långfile1') + command('sp långfile2') feed(':b lå') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {3:långfile2 }| | {2:långfile1 }| | - ]], popupmenu={ - anchor = { -1, 0, 2 }, - items = {{ "långfile1", "", "", "" }, { "långfile2", "", "", "" }}, - pos = 0 - }, cmdline={{ - content = {{ "b långfile1" }}, - firstc = ":", - pos = 12 - }}} + ]], + popupmenu = { + anchor = { -1, 0, 2 }, + items = { { 'långfile1', '', '', '' }, { 'långfile2', '', '', '' } }, + pos = 0, + }, + cmdline = { + { + content = { { 'b långfile1' } }, + firstc = ':', + pos = 12, + }, + }, + } end) it('ext_wildmenu takes precedence over ext_popupmenu', function() @@ -577,15 +776,22 @@ local function test_cmdline(linegrid) screen:set_option('ext_popupmenu', true) feed(':sign ') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign define"}}, - pos = 11, - }}, wildmenu_items=expected, wildmenu_pos=0} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign define' } }, + pos = 11, + }, + }, + wildmenu_items = expected, + wildmenu_pos = 0, + } end) it("doesn't send invalid events when aborting mapping #10000", function() @@ -593,16 +799,21 @@ local function test_cmdline(linegrid) command('cnoremap ab c') feed(':xa') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]], cmdline={{ - content = { { "x" } }, - firstc = ":", - pos = 1, - special = { "a", false } - }}} + ]], + cmdline = { + { + content = { { 'x' } }, + firstc = ':', + pos = 1, + special = { 'a', false }, + }, + }, + } -- This used to send an invalid event where pos where larger than the total -- length of content. Checked in _handle_cmdline_show. @@ -613,61 +824,75 @@ local function test_cmdline(linegrid) | ]]) end) - end -- the representation of cmdline and cmdline_block contents changed with ext_linegrid -- (which uses indexed highlights) so make sure to test both -describe('ui/ext_cmdline', function() test_cmdline(true) end) -describe('ui/ext_cmdline (legacy highlights)', function() test_cmdline(false) end) +describe('ui/ext_cmdline', function() + test_cmdline(true) +end) +describe('ui/ext_cmdline (legacy highlights)', function() + test_cmdline(false) +end) describe('cmdline redraw', function() local screen before_each(function() clear() - screen = new_screen({rgb=true}) + screen = new_screen({ rgb = true }) end) it('with timer', function() feed(':012345678901234567890123456789') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| :012345678901234567890123| 456789^ | - ]]} + ]], + } command('call timer_start(0, {-> 1})') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| :012345678901234567890123| 456789^ | - ]], unchanged=true, timeout=100} + ]], + unchanged = true, + timeout = 100, + } end) it('with ', function() if is_os('bsd') then pending('FIXME #10804') end - command('cmap a call sin(0)') -- no-op + command('cmap a call sin(0)') -- no-op feed(':012345678901234567890123456789') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| :012345678901234567890123| 456789^ | - ]]} + ]], + } feed('a') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| :012345678901234567890123| 456789^ | - ]], unchanged=true} + ]], + unchanged = true, + } end) it('after pressing Ctrl-C in cmdwin in Visual mode #18967', function() @@ -697,64 +922,80 @@ describe('cmdline redraw', function() it('with rightleftcmd', function() command('set rightleft rightleftcmd=search shortmess+=s') - meths.buf_set_lines(0, 0, -1, true, {"let's rock!"}) - screen:expect{grid=[[ + meths.buf_set_lines(0, 0, -1, true, { "let's rock!" }) + screen:expect { + grid = [[ !kcor s'te^l| {1: ~}|*3 | - ]]} + ]], + } feed '/' - screen:expect{grid=[[ + screen:expect { + grid = [[ !kcor s'tel| {1: ~}|*3 ^ /| - ]]} + ]], + } feed "let's" -- note: cursor looks off but looks alright in real use -- when rendered as a block so it touches the end of the text - screen:expect{grid=[[ + screen:expect { + grid = [[ !kcor {2:s'tel}| {1: ~}|*3 ^ s'tel/| - ]]} + ]], + } -- cursor movement - feed "" - screen:expect{grid=[[ + feed '' + screen:expect { + grid = [[ !kcor{2: s'tel}| {1: ~}|*3 ^ s'tel/| - ]]} + ]], + } - feed "rock" - screen:expect{grid=[[ + feed 'rock' + screen:expect { + grid = [[ !{2:kcor s'tel}| {1: ~}|*3 ^ kcor s'tel/| - ]]} + ]], + } - feed "" - screen:expect{grid=[[ + feed '' + screen:expect { + grid = [[ !{2:kcor s'tel}| {1: ~}|*3 ^kcor s'tel/| - ]]} + ]], + } - feed "" - screen:expect{grid=[[ + feed '' + screen:expect { + grid = [[ !{2:kcor s'tel}| {1: ~}|*3 ^ kcor s'tel/| - ]]} + ]], + } - feed "" - screen:expect{grid=[[ + feed '' + screen:expect { + grid = [[ !{10:kcor s'te^l}| {1: ~}|*3 kcor s'tel/ | - ]]} + ]], + } end) end) @@ -769,44 +1010,52 @@ describe('statusline is redrawn on entering cmdline', function() it('from normal mode', function() command('set statusline=%{mode()}') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*2 {3:n }| | - ]]} + ]], + } feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }|*2 {3:c }| :^ | - ]]} + ]], + } end) it('from normal mode when : is mapped', function() command('set statusline=%{mode()}') command('nnoremap ; :') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*2 {3:n }| | - ]]} + ]], + } feed(';') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }|*2 {3:c }| :^ | - ]]} + ]], + } end) it('with scrolled messages', function() - screen:try_resize(35,14) + screen:try_resize(35, 14) exec([[ let g:count = 0 autocmd CmdlineEnter * let g:count += 1 @@ -816,7 +1065,8 @@ describe('statusline is redrawn on entering cmdline', function() setlocal winbar=%{mode()}%{g:count} ]]) feed(':echoerr doesnotexist') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:c1 }| | {3:c1 }| @@ -827,9 +1077,11 @@ describe('statusline is redrawn on entering cmdline', function() {4:ist} | {5:Press ENTER or type command to cont}| {5:inue}^ | - ]]} + ]], + } feed(':echoerr doesnotexist') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:c2 }| | {3:c2 }| @@ -843,10 +1095,12 @@ describe('statusline is redrawn on entering cmdline', function() {4:ist} | {5:Press ENTER or type command to cont}| {5:inue}^ | - ]]} + ]], + } feed(':echoerr doesnotexist') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:c3 }| | {3:c3 }| @@ -861,10 +1115,12 @@ describe('statusline is redrawn on entering cmdline', function() {4:ist} | {5:Press ENTER or type command to cont}| {5:inue}^ | - ]]} + ]], + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:n3 }| ^ | {3:n3 }| @@ -872,40 +1128,47 @@ describe('statusline is redrawn on entering cmdline', function() {1:~ }|*8 {2:[No Name] }| | - ]]} + ]], + } end) describe('if custom statusline is set by', function() before_each(function() command('set statusline=') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*2 {3:[No Name] }| | - ]]} + ]], + } end) it('CmdlineEnter autocommand', function() command('autocmd CmdlineEnter * set statusline=command') feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }|*2 {3:command }| :^ | - ]]} + ]], + } end) it('ModeChanged autocommand', function() command('autocmd ModeChanged *:c set statusline=command') feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }|*2 {3:command }| :^ | - ]]} + ]], + } end) end) end) @@ -914,9 +1177,9 @@ it('tabline is not redrawn in Ex mode #24122', function() clear() local screen = Screen.new(60, 5) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText - [1] = {bold = true, reverse = true}, -- MsgSeparator - [2] = {reverse = true}, -- TabLineFill + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [1] = { bold = true, reverse = true }, -- MsgSeparator + [2] = { reverse = true }, -- TabLineFill }) screen:attach() @@ -931,28 +1194,32 @@ it('tabline is not redrawn in Ex mode #24122', function() ]]) feed('gQ') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:foo }| | {1: }| Entering Ex mode. Type "visual" to go to Normal mode. | :^ | - ]]} + ]], + } feed('echo 1') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }| Entering Ex mode. Type "visual" to go to Normal mode. | :echo 1 | 1 | :^ | - ]]} + ]], + } end) -describe("cmdline height", function() +describe('cmdline height', function() before_each(clear) - it("does not crash resized screen #14263", function() + it('does not crash resized screen #14263', function() local screen = Screen.new(25, 10) screen:attach() command('set cmdheight=9999') @@ -976,254 +1243,320 @@ describe('cmdheight=0', function() clear() screen = Screen.new(25, 5) screen:set_default_attr_ids { - [1] = {bold = true, foreground = Screen.colors.Blue}; - [2] = {bold = true, reverse = true}; - [3] = {bold = true}; - [4] = {foreground = Screen.colors.White, background = Screen.colors.Red}; - [5] = {foreground = Screen.colors.SeaGreen4, bold = true}; - [6] = {reverse = true}; - [7] = {background = Screen.colors.Yellow}; + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { bold = true, reverse = true }, + [3] = { bold = true }, + [4] = { foreground = Screen.colors.White, background = Screen.colors.Red }, + [5] = { foreground = Screen.colors.SeaGreen4, bold = true }, + [6] = { reverse = true }, + [7] = { background = Screen.colors.Yellow }, } screen:attach() end) - it("with redrawdebug=invalid resize -1", function() - command("set redrawdebug=invalid cmdheight=0 noruler laststatus=0") - screen:expect{grid=[[ + it('with redrawdebug=invalid resize -1', function() + command('set redrawdebug=invalid cmdheight=0 noruler laststatus=0') + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]]} - feed(":resize -1") - screen:expect{grid=[[ + ]], + } + feed(':resize -1') + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]]} + ]], + } assert_alive() end) - it("with cmdheight=1 noruler laststatus=2", function() - command("set cmdheight=1 noruler laststatus=2") - screen:expect{grid=[[ + it('with cmdheight=1 noruler laststatus=2', function() + command('set cmdheight=1 noruler laststatus=2') + screen:expect { + grid = [[ ^ | {1:~ }|*2 {2:[No Name] }| | - ]]} + ]], + } end) - it("with cmdheight=0 noruler laststatus=2", function() - command("set cmdheight=0 noruler laststatus=2") - screen:expect{grid=[[ + it('with cmdheight=0 noruler laststatus=2', function() + command('set cmdheight=0 noruler laststatus=2') + screen:expect { + grid = [[ ^ | {1:~ }|*3 {2:[No Name] }| - ]]} + ]], + } end) - it("with cmdheight=0 ruler laststatus=0", function() - command("set cmdheight=0 ruler laststatus=0") - screen:expect{grid=[[ + it('with cmdheight=0 ruler laststatus=0', function() + command('set cmdheight=0 ruler laststatus=0') + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]]} + ]], + } end) - it("with cmdheight=0 ruler laststatus=0", function() - command("set cmdheight=0 noruler laststatus=0 showmode") + it('with cmdheight=0 ruler laststatus=0', function() + command('set cmdheight=0 noruler laststatus=0 showmode') feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={}} + ]], + showmode = {}, + } feed('') eq(0, eval('&cmdheight')) end) - it("with cmdheight=0 ruler rulerformat laststatus=0", function() - command("set cmdheight=0 noruler laststatus=0 rulerformat=%l,%c%= showmode") + it('with cmdheight=0 ruler rulerformat laststatus=0', function() + command('set cmdheight=0 noruler laststatus=0 rulerformat=%l,%c%= showmode') feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={}} + ]], + showmode = {}, + } feed('') eq(0, eval('&cmdheight')) end) - it("with showmode", function() - command("set cmdheight=1 noruler laststatus=0 showmode") + it('with showmode', function() + command('set cmdheight=1 noruler laststatus=0 showmode') feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 {3:-- INSERT --} | - ]]} + ]], + } feed('') eq(1, eval('&cmdheight')) end) - it("when using command line", function() - command("set cmdheight=0 noruler laststatus=0") + it('when using command line', function() + command('set cmdheight=0 noruler laststatus=0') feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }|*3 :^ | - ]]} + ]], + } eq(0, eval('&cmdheight')) feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={}} + ]], + showmode = {}, + } eq(0, eval('&cmdheight')) end) - it("when using input()", function() - command("set cmdheight=0 noruler laststatus=0") + it('when using input()', function() + command('set cmdheight=0 noruler laststatus=0') feed(':call input("foo >")') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {2: }| :call input("foo >") | foo >^ | - ]]} + ]], + } eq(0, eval('&cmdheight')) feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={}} + ]], + showmode = {}, + } eq(0, eval('&cmdheight')) end) - it("with winbar and splits", function() - command("set cmdheight=0 noruler laststatus=3 winbar=foo") + it('with winbar and splits', function() + command('set cmdheight=0 noruler laststatus=3 winbar=foo') feed(':split') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2: }| :split | {4:E36: Not enough room} | {5:Press ENTER or type comma}| {5:nd to continue}^ | - ]]} + ]], + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:foo }| ^ | {1:~ }|*2 {2:[No Name] }| - ]]} + ]], + } feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:foo }| | {1:~ }|*2 :^ | - ]]} + ]], + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:foo }| ^ | {1:~ }|*2 {2:[No Name] }| - ]], showmode={}} + ]], + showmode = {}, + } eq(0, eval('&cmdheight')) assert_alive() end) - it("when macro with lastline", function() - command("set cmdheight=0 display=lastline") + it('when macro with lastline', function() + command('set cmdheight=0 display=lastline') feed('qq') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]]} + ]], + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], unchanged=true} + ]], + unchanged = true, + } end) - it("when substitute text", function() - command("set cmdheight=0 noruler laststatus=3") + it('when substitute text', function() + command('set cmdheight=0 noruler laststatus=3') feed('ifoo') - screen:expect{grid=[[ + screen:expect { + grid = [[ fo^o | {1:~ }|*3 {2:[No Name] [+] }| - ]]} + ]], + } feed(':%s/foo/bar/gc') - screen:expect{grid=[[ + screen:expect { + grid = [[ {6:foo} | {1:~ }|*3 {5:replace wi...q/l/^E/^Y)?}^ | - ]]} + ]], + } feed('y') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^bar | {1:~ }|*3 {2:[No Name] [+] }| - ]]} + ]], + } assert_alive() end) - it("when window resize", function() - command("set cmdheight=0") + it('when window resize', function() + command('set cmdheight=0') feed('+') eq(0, eval('&cmdheight')) end) - it("with non-silent mappings with cmdline", function() - command("set cmdheight=0") - command("map :nohlsearch") + it('with non-silent mappings with cmdline', function() + command('set cmdheight=0') + command('map :nohlsearch') feed('iaabbaa/aa') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:^aa}bb{7:aa} | {1:~ }|*4 - ]]} + ]], + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^aabbaa | {1:~ }|*4 - ]]} + ]], + } end) it('with silent! at startup', function() - clear{args={'-c', 'set cmdheight=0', '-c', 'autocmd VimEnter * silent! call Foo()'}} + clear { args = { '-c', 'set cmdheight=0', '-c', 'autocmd VimEnter * silent! call Foo()' } } screen:attach() -- doesn't crash while not displaying silent! error message - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]]} + ]], + } end) it('with multigrid', function() - clear{args={'--cmd', 'set cmdheight=0'}} - screen:attach{ext_multigrid=true} - meths.buf_set_lines(0, 0, -1, true, {'p'}) - screen:expect{grid=[[ + clear { args = { '--cmd', 'set cmdheight=0' } } + screen:attach { ext_multigrid = true } + meths.buf_set_lines(0, 0, -1, true, { 'p' }) + screen:expect { + grid = [[ ## grid 1 [2:-------------------------]|*5 ## grid 2 ^p | {1:~ }|*4 ## grid 3 - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = { id = 1000 }, + topline = 0, + botline = 2, + curline = 0, + curcol = 0, + linecount = 1, + sum_scroll_delta = 0, + }, + }, + } feed '/p' - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 [2:-------------------------]|*4 [3:-------------------------]| @@ -1232,9 +1565,19 @@ describe('cmdheight=0', function() {1:~ }|*4 ## grid 3 /p^ | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = { id = 1000 }, + topline = 0, + botline = 2, + curline = 0, + curcol = 0, + linecount = 1, + sum_scroll_delta = 0, + }, + }, + } end) it('winbar is redrawn on entering cmdline and :redrawstatus #20336', function() @@ -1324,18 +1667,22 @@ describe('cmdheight=0', function() | ]]) command('set cmdheight=0') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 {2:[No Name] }| - ]]} + ]], + } command('resize -1') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*2 {2:[No Name] }| | - ]]} + ]], + } command('resize +1') screen:expect([[ ^ | @@ -1344,9 +1691,9 @@ describe('cmdheight=0', function() ]]) end) - it("cannot be resized at all with external messages", function() + it('cannot be resized at all with external messages', function() clear() - screen = new_screen({rgb=true, ext_messages=true}) + screen = new_screen({ rgb = true, ext_messages = true }) command('set laststatus=2 mouse=a') command('resize -1') screen:expect([[ -- cgit From c30f2e3182e3b50e7c03932027ac55edfc8ada4a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 12:44:54 +0000 Subject: test: typing for helpers.meths --- test/functional/ui/cmdline_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 82ff633fcb..2670288cbb 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -922,7 +922,7 @@ describe('cmdline redraw', function() it('with rightleftcmd', function() command('set rightleft rightleftcmd=search shortmess+=s') - meths.buf_set_lines(0, 0, -1, true, { "let's rock!" }) + meths.nvim_buf_set_lines(0, 0, -1, true, { "let's rock!" }) screen:expect { grid = [[ !kcor s'te^l| @@ -1531,7 +1531,7 @@ describe('cmdheight=0', function() it('with multigrid', function() clear { args = { '--cmd', 'set cmdheight=0' } } screen:attach { ext_multigrid = true } - meths.buf_set_lines(0, 0, -1, true, { 'p' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'p' }) screen:expect { grid = [[ ## grid 1 @@ -1701,9 +1701,9 @@ describe('cmdheight=0', function() {1:~ }|*3 {3:[No Name] }| ]]) - meths.input_mouse('left', 'press', '', 0, 6, 10) + meths.nvim_input_mouse('left', 'press', '', 0, 6, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 5, 10) + meths.nvim_input_mouse('left', 'drag', '', 0, 5, 10) screen:expect_unchanged() end) end) -- cgit From 795f896a5772d5e0795f86642bdf90c82efac45c Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 17:59:57 +0000 Subject: test: rename (meths, funcs) -> (api, fn) --- test/functional/ui/cmdline_spec.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 2670288cbb..40221269a8 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -9,7 +9,7 @@ local exec = helpers.exec local eval = helpers.eval local eq = helpers.eq local is_os = helpers.is_os -local meths = helpers.meths +local api = helpers.api local function new_screen(opt) local screen = Screen.new(25, 5) @@ -922,7 +922,7 @@ describe('cmdline redraw', function() it('with rightleftcmd', function() command('set rightleft rightleftcmd=search shortmess+=s') - meths.nvim_buf_set_lines(0, 0, -1, true, { "let's rock!" }) + api.nvim_buf_set_lines(0, 0, -1, true, { "let's rock!" }) screen:expect { grid = [[ !kcor s'te^l| @@ -1531,7 +1531,7 @@ describe('cmdheight=0', function() it('with multigrid', function() clear { args = { '--cmd', 'set cmdheight=0' } } screen:attach { ext_multigrid = true } - meths.nvim_buf_set_lines(0, 0, -1, true, { 'p' }) + api.nvim_buf_set_lines(0, 0, -1, true, { 'p' }) screen:expect { grid = [[ ## grid 1 @@ -1701,9 +1701,9 @@ describe('cmdheight=0', function() {1:~ }|*3 {3:[No Name] }| ]]) - meths.nvim_input_mouse('left', 'press', '', 0, 6, 10) + api.nvim_input_mouse('left', 'press', '', 0, 6, 10) poke_eventloop() - meths.nvim_input_mouse('left', 'drag', '', 0, 5, 10) + api.nvim_input_mouse('left', 'drag', '', 0, 5, 10) screen:expect_unchanged() end) end) -- cgit From 8f02ae82e203920b472d17e75a61763f3a409a7b Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 16 Jan 2024 13:26:21 +0000 Subject: test: use integers for API Buffer/Window/Tabpage EXT types --- test/functional/ui/cmdline_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 40221269a8..9aee2ee103 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -1543,7 +1543,7 @@ describe('cmdheight=0', function() ]], win_viewport = { [2] = { - win = { id = 1000 }, + win = 1000, topline = 0, botline = 2, curline = 0, @@ -1568,7 +1568,7 @@ describe('cmdheight=0', function() ]], win_viewport = { [2] = { - win = { id = 1000 }, + win = 1000, topline = 0, botline = 2, curline = 0, -- 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/cmdline_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/cmdline_spec.lua') diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 9aee2ee103..0eb5770819 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -22,7 +22,7 @@ local function new_screen(opt) [5] = { bold = true, foreground = Screen.colors.SeaGreen4 }, [6] = { foreground = Screen.colors.Magenta }, [7] = { bold = true, foreground = Screen.colors.Brown }, - [8] = { background = Screen.colors.LightGrey }, + [8] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey }, [9] = { bold = true }, [10] = { background = Screen.colors.Yellow1 }, }) -- cgit