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/messages_spec.lua | 561 +++++++---------------------------- 1 file changed, 107 insertions(+), 454 deletions(-) (limited to 'test/functional/ui/messages_spec.lua') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 1d11a12af4..85895b2c36 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -50,10 +50,7 @@ describe('ui/ext_messages', function() feed(':call confirm("test")') screen:expect{grid=[[ line ^1 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={ { content = {{"\ntest\n[O]k: ", 4}}, kind = 'confirm', @@ -62,10 +59,7 @@ describe('ui/ext_messages', function() feed('') screen:expect{grid=[[ line ^1 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} end) @@ -77,9 +71,7 @@ describe('ui/ext_messages', function() screen:expect{grid=[[ line 1 | line ^2 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], messages={ { content = {{"\ntest\n[O]k: ", 4}}, kind = 'confirm', @@ -88,9 +80,7 @@ describe('ui/ext_messages', function() screen:expect{grid=[[ line 1 | line ^2 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], messages={ { content = { { "\ntest\n[O]k: ", 4 } }, kind = "confirm" @@ -108,9 +98,7 @@ describe('ui/ext_messages', function() screen:expect{grid=[[ l{7:i}ne 1 | l{8:i}ne ^2 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], attr_ids={ [1] = {bold = true, foreground = Screen.colors.Blue1}, [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, @@ -133,9 +121,7 @@ describe('ui/ext_messages', function() screen:expect{grid=[[ line 1 | {MATCH:.*}| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], attr_ids={ [1] = {bold = true, foreground = Screen.colors.Blue1}, [7] = {foreground = Screen.colors.Red}, @@ -150,9 +136,7 @@ describe('ui/ext_messages', function() screen:expect{grid=[[ l^ine 1 | line 2 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], attr_ids={ [1] = {bold = true, foreground = Screen.colors.Blue1}, [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, @@ -171,9 +155,7 @@ describe('ui/ext_messages', function() screen:expect{grid=[[ l^ine 1 | line 2 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], messages={ { content = { { "Error detected while processing :", 2 } }, kind = "emsg" @@ -193,9 +175,7 @@ describe('ui/ext_messages', function() screen:expect{grid=[[ line 1 | ^line 2 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], messages={ { content = { { "(2 of 2): line2" } }, kind = "quickfix" @@ -206,10 +186,7 @@ describe('ui/ext_messages', function() feed(':echoerr "raa"') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{"raa", 2}}, kind = "echoerr", @@ -219,10 +196,7 @@ describe('ui/ext_messages', function() feed(':') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], cmdline={{ firstc = ":", content = {{ "" }}, @@ -233,10 +207,7 @@ describe('ui/ext_messages', function() feed('echoerr "bork" | echoerr "fail"') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{ "bork", 2 }}, kind = "echoerr" @@ -251,10 +222,7 @@ describe('ui/ext_messages', function() feed(':echoerr "extrafail"') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = { { "bork", 2 } }, kind = "echoerr" @@ -272,20 +240,14 @@ describe('ui/ext_messages', function() feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} -- cmdline without interleaving wait/display keeps the error message feed(':echoerr "problem" | let x = input("foo> ")') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{ "problem", 2 }}, kind = "echoerr" @@ -298,20 +260,14 @@ describe('ui/ext_messages', function() feed('solution') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} eq('solution', eval('x')) feed(":messages") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], msg_history={ {kind="echoerr", content={{"raa", 2}}}, {kind="echoerr", content={{"bork", 2}}}, @@ -326,10 +282,7 @@ describe('ui/ext_messages', function() feed '' screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} end) @@ -338,10 +291,7 @@ describe('ui/ext_messages', function() feed(':echoerr g:multi') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{ "bork\nfail", 2 }}, kind = "echoerr" @@ -350,10 +300,7 @@ describe('ui/ext_messages', function() feed(':messages') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{ "Press ENTER or type command to continue", 4 }}, kind = "return_prompt" @@ -371,9 +318,7 @@ describe('ui/ext_messages', function() screen:expect{grid=[[ {7:^line} 1 | {7:line} 2 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], messages={ {content = {{"/line W [1/2]"}}, kind = "search_count"} }} @@ -382,9 +327,7 @@ describe('ui/ext_messages', function() screen:expect{grid=[[ {7:line} 1 | {7:^line} 2 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], messages={ {content = {{"/line [2/2]"}}, kind = "search_count"} }} @@ -394,10 +337,7 @@ describe('ui/ext_messages', function() feed(':hi ErrorMsg') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={ {content = {{"\nErrorMsg " }, {"xxx", 2}, {" "}, {"ctermfg=", 5 }, { "15 " }, { "ctermbg=", 5 }, { "1 " }, @@ -411,10 +351,7 @@ describe('ui/ext_messages', function() feed(':let x y') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={ {content = {{ "x #1" }}, kind = ""}, {content = {{ "y #2" }}, kind = ""}, @@ -427,10 +364,7 @@ describe('ui/ext_messages', function() feed('i') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={{"-- INSERT --", 3}}} feed('alphpabetalphanum') @@ -438,8 +372,7 @@ describe('ui/ext_messages', function() alphpabet | alphanum | ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 ]], showmode={ { "-- INSERT --", 3 } }} feed('') @@ -447,8 +380,7 @@ describe('ui/ext_messages', function() alphpabet | alphanum | ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 ]], showmode={ { "-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)", 3 } }} feed('') @@ -456,8 +388,7 @@ describe('ui/ext_messages', function() alphpabet | alphanum | alphanum^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 ]], popupmenu={ anchor = { 1, 2, 0 }, items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, @@ -471,8 +402,7 @@ describe('ui/ext_messages', function() alphpabet | alphanum | alphanum^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 ]], popupmenu={ anchor = { 1, 2, 0 }, items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, @@ -487,8 +417,7 @@ describe('ui/ext_messages', function() alphpabet | alphanum | alphpabet^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 ]], popupmenu={ anchor = { 1, 2, 0 }, items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, @@ -503,8 +432,7 @@ describe('ui/ext_messages', function() alphpabet | alphanum | alphpabe^t | - {1:~ }| - {1:~ }| + {1:~ }|*2 ]], msg_history={{ content = {{ "stuff" }}, kind = "echomsg", @@ -518,37 +446,25 @@ describe('ui/ext_messages', function() feed('qq') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={ { "recording @q", 3 } }} feed('i') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={ { "-- INSERT --recording @q", 3 } }} feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={ { "recording @q", 3 } }} feed('q') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]) end) @@ -558,37 +474,25 @@ describe('ui/ext_messages', function() -- also check mode to avoid immediate success screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={ { "recording @q", 3 } }, mode="normal"} feed('i') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={ { "recording @q", 3 } }, mode="insert"} feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={ { "recording @q", 3 } }, mode="normal"} feed('q') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], mode="normal"} end) @@ -596,66 +500,48 @@ describe('ui/ext_messages', function() command('set showcmd ruler') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], ruler={ { "0,0-1 All" } }} feed('i') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], showmode={ { "-- INSERT --", 3 } }, ruler={ { "0,1 All" } }} feed('abcde12345') screen:expect{grid=[[ abcde | 1234^5 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], ruler={ { "2,5 All" } }} feed('d') screen:expect{grid=[[ abcde | 1234^5 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], showcmd={ { "d" } }, ruler={ { "2,5 All" } }} feed('^') screen:expect{grid=[[ abcde | ^12345 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], ruler={ { "2,1 All" } }} feed('d') screen:expect{grid=[[ abcde | ^12345 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], showcmd={ { "d" } }, ruler={ { "2,1 All" } }} feed('i') screen:expect{grid=[[ abcde | ^12345 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], showcmd={ { "di" } }, ruler={ { "2,1 All" } }} feed('w') screen:expect{grid=[[ abcde | ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]], ruler={ { "2,0-1 All" } }} -- when ruler is part of statusline it is not externalized. @@ -664,8 +550,7 @@ describe('ui/ext_messages', function() screen:expect([[ abcde | ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {6:') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{ "howdy" }}, kind = "echomsg"} }} @@ -687,10 +569,7 @@ describe('ui/ext_messages', function() feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{ "Type :qa and press to exit Nvim" }}, kind = ""} @@ -699,10 +578,7 @@ describe('ui/ext_messages', function() feed(':echoerr "bork"') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{ "bork", 2 }}, kind = "echoerr"} }} @@ -710,10 +586,7 @@ describe('ui/ext_messages', function() feed(':echo "xyz"') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{ "xyz" }}, kind = "echo"} }} @@ -721,10 +594,7 @@ describe('ui/ext_messages', function() feed(':call nosuchfunction()') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{ "E117: Unknown function: nosuchfunction", 2 }}, kind = "emsg"} @@ -733,10 +603,7 @@ describe('ui/ext_messages', function() feed(':messages') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], msg_history={ {kind="echomsg", content={{"howdy"}}}, {kind="", content={{"Type :qa and press to exit Nvim"}}}, @@ -753,10 +620,7 @@ describe('ui/ext_messages', function() feed(':set cmdheight=1') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], cmdline={{ content = { { "set cmdheight=1" } }, firstc = ":", @@ -766,20 +630,14 @@ describe('ui/ext_messages', function() feed('') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]) eq(0, eval('&cmdheight')) feed(':set cmdheight=0') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], cmdline={{ content = { { "set cmdheight=0" } }, firstc = ":", @@ -788,10 +646,7 @@ describe('ui/ext_messages', function() feed('') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]) eq(0, eval('&cmdheight')) end) @@ -800,10 +655,7 @@ describe('ui/ext_messages', function() feed(':lua error("such\\nmultiline\\nerror")') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{[[E5108: Error executing lua [string ":lua"]:1: such multiline @@ -820,10 +672,7 @@ stack traceback: screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={{ content = {{"Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 2}}, kind = "rpc_error" @@ -855,12 +704,7 @@ stack traceback: feed(':set wildm') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ]], messages={{ content = {{'wildmenu wildmode'}}, kind = '', @@ -879,9 +723,7 @@ stack traceback: feed('z=') screen:expect{grid=[[ {9:helllo} | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {1:^~ }| ]], messages={ {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and or click with the mouse (q or empty cancels): ' } }, kind = ""} @@ -890,9 +732,7 @@ stack traceback: feed('1') screen:expect{grid=[[ {9:helllo} | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {1:^~ }| ]], messages={ {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and or click with the mouse (q or empty cancels): ' } }, kind = ""}, @@ -902,10 +742,7 @@ stack traceback: feed('') screen:expect{grid=[[ ^Hello | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} end) @@ -913,10 +750,7 @@ stack traceback: async_meths.echo({{'wow, ',"Search"}, {"such\n\nvery ", "ErrorMsg"}, {"color", "LineNr"}}, true, {}) screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={ { content = { { "wow, ", 7 }, { "such\n\nvery ", 2 }, { "color", 10 } }, kind = "echomsg" } }} @@ -924,10 +758,7 @@ stack traceback: feed ':ls' screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={ { content = { { '\n 1 %a "[No Name]" line 1' } }, kind = "" } }} @@ -935,10 +766,7 @@ stack traceback: feed ':messages' screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], messages={ { content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" } }, msg_history={ @@ -948,10 +776,7 @@ stack traceback: feed '' screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} end) @@ -1007,8 +832,7 @@ describe('ui/builtin messages', function() feed(':hi ErrorMsg') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3: }| :hi ErrorMsg | ErrorMsg {2:xxx} {5:ctermfg=}15 {5:ctermbg=}1 {5:guifg=}White {5:guibg=}Red | @@ -1092,31 +916,19 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim feed(':call T1()') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 message T1 | ]]} feed(':call T2()') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 message T2 | ]]} feed(':call T3()') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 message T3 | ]]} end) @@ -1125,33 +937,21 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim command("set ruler laststatus=0") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 0,0-1 All | ]]} command("hi MsgArea guibg=#333333") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {7: 0,0-1 All }| ]]} command("set rulerformat=%15(%c%V\\ %p%%%)") screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {7: 0,0-1 100% }| ]]} end) @@ -1160,8 +960,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim feed(':echo "line 1\\r\\nline 2"') screen:expect{grid=[[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3: }| line 1 | line 2 | @@ -1171,11 +970,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim feed(':echo "abc\\rz"') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 zbc | ]]} end) @@ -1245,8 +1040,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim feed(':set colorcolumn=5 | lua error("x\\n\\n\\nx")') screen:expect{grid=[[ {2:E5108: Error executing lua [string ":lua"]:1: x} | - | - | + |*2 {2:x} | {2:stack traceback:} | {2: [C]: in function 'error'} | @@ -1255,8 +1049,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim feed('') screen:expect{grid=[[ - | - | + |*2 {2:x} | {2:stack traceback:} | {2: [C]: in function 'error'} | @@ -1280,11 +1073,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim feed '' screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]} @@ -1319,8 +1108,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {11: 2 }^bbb | {11: 3 }ccc | {11: 4 } | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) end) @@ -1341,9 +1129,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim feed(':call PrintAndWait()') screen:expect{grid=[[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {3: }| aaa | bbb^ | @@ -1383,9 +1169,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim ]], false) screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {3: }| | {4:Press ENTER or type command to continue}^ | @@ -1393,11 +1177,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim feed('') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]) eq(1, meths.get_option_value('cmdheight', {})) @@ -1408,9 +1188,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim screen:try_resize(60, 5) screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) eq({ mode = 'n', blocking = false }, meths.get_mode()) @@ -1451,10 +1229,7 @@ describe('ui/ext_messages', function() -- Note parts of it depends on version or is indeterministic. We ignore those parts. screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {MATCH:.*}| {1:~ }| {1:~ }Nvim is open source and freely distributable{1: }| @@ -1467,50 +1242,20 @@ describe('ui/ext_messages', function() {1:~ }| {1:~{MATCH: +}}type :help news{5:} to see changes in v{MATCH:%d+%.%d+}{1:{MATCH: +}}| {1:~ }| - {MATCH:.*}| - {MATCH:.*}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {MATCH:.*}|*2 + {1:~ }|*5 ]]) feed("") screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*23 ]]) feed(":intro") screen:expect{grid=[[ ^ | - | - | - | - | + |*4 {MATCH:.*}| | Nvim is open source and freely distributable | @@ -1523,13 +1268,8 @@ describe('ui/ext_messages', function() | {MATCH: +}type :help news{5:} to see changes in v{MATCH:%d+%.%d+ +}| | - {MATCH:.*}| - {MATCH:.*}| - | - | - | - | - | + {MATCH:.*}|*2 + |*5 ]], messages={ {content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" } }} @@ -1541,28 +1281,10 @@ describe('ui/ext_messages', function() feed(":set cmdheight") screen:expect({grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ────────────────────────────────────────────────────────────────────────────────| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 {7:[No Name] }| ]], messages={ {content = { { " cmdheight=0" } }, kind = "" } @@ -1572,28 +1294,10 @@ describe('ui/ext_messages', function() feed(":set laststatus") screen:expect({grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ────────────────────────────────────────────────────────────────────────────────| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*9 {7:[No Name] }| ]], messages={ {content = { { " laststatus=3" } }, kind = "" } @@ -1607,28 +1311,10 @@ describe('ui/ext_messages', function() feed(":set cmdheight") screen:expect({grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ────────────────────────────────────────────────────────────────────────────────| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 {7:[No Name] }| ]], messages={ {content = { { " cmdheight=0" } }, kind = "" } @@ -1726,9 +1412,7 @@ aliquip ex ea commodo consequat.]]) feed('q') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} end) @@ -1748,9 +1432,7 @@ aliquip ex ea commodo consequat.]]) feed('q') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} feed(':mess') @@ -2064,10 +1746,7 @@ aliquip ex ea commodo consequat.]]) feed(':!sleep 1') screen:expect{grid=[[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {12: }| :!sleep 1 | | @@ -2080,8 +1759,7 @@ aliquip ex ea commodo consequat.]]) -- before the "press ENTER" prompt though screen:expect{grid=[[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {12: }| :!sleep 1 | | @@ -2092,9 +1770,7 @@ aliquip ex ea commodo consequat.]]) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} end) @@ -2134,9 +1810,7 @@ aliquip ex ea commodo consequat.]]) {2:mpore} | {2:incididunt ut labore et dolore}| {2:a aliqua.} | - | - | - | + |*3 {4:-- More --}^ | ]]} @@ -2177,16 +1851,7 @@ aliquip ex ea commodo consequat.]]) feed('q') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 | ]]} end) @@ -2208,13 +1873,7 @@ aliquip ex ea commodo consequat.]]) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 ]]} feed('g') @@ -2232,13 +1891,7 @@ aliquip ex ea commodo consequat.]]) feed('') screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 ]]} end) 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/messages_spec.lua | 1655 ++++++++++++++++++++++------------ 1 file changed, 1061 insertions(+), 594 deletions(-) (limited to 'test/functional/ui/messages_spec.lua') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 85895b2c36..2a402437fd 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -27,18 +27,18 @@ describe('ui/ext_messages', function() before_each(function() clear() screen = Screen.new(25, 5) - screen:attach({rgb=true, ext_messages=true, ext_popupmenu=true}) + screen:attach({ rgb = true, ext_messages = true, ext_popupmenu = true }) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {bold = true}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {foreground = Screen.colors.Blue1}, - [6] = {bold = true, reverse = true}, - [7] = {background = Screen.colors.Yellow}, - [8] = {foreground = Screen.colors.Red}, - [9] = {special = Screen.colors.Red, undercurl = true}, - [10] = {foreground = Screen.colors.Brown}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { foreground = Screen.colors.Blue1 }, + [6] = { bold = true, reverse = true }, + [7] = { background = Screen.colors.Yellow }, + [8] = { foreground = Screen.colors.Red }, + [9] = { special = Screen.colors.Red, undercurl = true }, + [10] = { foreground = Screen.colors.Brown }, }) end) after_each(function() @@ -48,19 +48,26 @@ describe('ui/ext_messages', function() it('msg_clear follows msg_show kind of confirm', function() feed('iline 1') feed(':call confirm("test")') - screen:expect{grid=[[ + screen:expect { + grid = [[ line ^1 | {1:~ }|*4 - ]], messages={ { - content = {{"\ntest\n[O]k: ", 4}}, - kind = 'confirm', - }}} + ]], + messages = { + { + content = { { '\ntest\n[O]k: ', 4 } }, + kind = 'confirm', + }, + }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ line ^1 | {1:~ }|*4 - ]]} + ]], + } end) it('msg_show kind=confirm,confirm_sub,emsg,wmsg,quickfix', function() @@ -68,246 +75,335 @@ describe('ui/ext_messages', function() -- kind=confirm feed(':echo confirm("test")') - screen:expect{grid=[[ + screen:expect { + grid = [[ line 1 | line ^2 | {1:~ }|*3 - ]], messages={ { - content = {{"\ntest\n[O]k: ", 4}}, - kind = 'confirm', - }}} + ]], + messages = { + { + content = { { '\ntest\n[O]k: ', 4 } }, + kind = 'confirm', + }, + }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ line 1 | line ^2 | {1:~ }|*3 - ]], messages={ { - content = { { "\ntest\n[O]k: ", 4 } }, - kind = "confirm" - }, { - content = { { "1" } }, - kind = "echo" - }, { - content = { { "Press ENTER or type command to continue", 4 } }, - kind = "return_prompt" - } }} + ]], + messages = { + { + content = { { '\ntest\n[O]k: ', 4 } }, + kind = 'confirm', + }, + { + content = { { '1' } }, + kind = 'echo', + }, + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } feed('') -- kind=confirm_sub feed(':%s/i/X/gc') - screen:expect{grid=[[ + screen:expect { + grid = [[ l{7:i}ne 1 | l{8:i}ne ^2 | {1:~ }|*3 - ]], attr_ids={ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {bold = true}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {foreground = Screen.colors.Blue1}, - [6] = {bold = true, reverse = true}, - [7] = {reverse = true}, - [8] = {background = Screen.colors.Yellow}, - }, messages={ { - content = { { "replace with X (y/n/a/q/l/^E/^Y)?", 4 } }, - kind = "confirm_sub" - } }} + ]], + attr_ids = { + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { foreground = Screen.colors.Blue1 }, + [6] = { bold = true, reverse = true }, + [7] = { reverse = true }, + [8] = { background = Screen.colors.Yellow }, + }, + messages = { + { + content = { { 'replace with X (y/n/a/q/l/^E/^Y)?', 4 } }, + kind = 'confirm_sub', + }, + }, + } feed('nq') -- kind=wmsg (editing readonly file) command('write ' .. fname) command('set readonly nohls') feed('G$x') - screen:expect{grid=[[ + screen:expect { + grid = [[ line 1 | {MATCH:.*}| {1:~ }|*3 - ]], attr_ids={ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [7] = {foreground = Screen.colors.Red}, - }, messages={ { - content = { { "W10: Warning: Changing a readonly file", 7 } }, - kind = "wmsg" - } - }} + ]], + attr_ids = { + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [7] = { foreground = Screen.colors.Red }, + }, + messages = { + { + content = { { 'W10: Warning: Changing a readonly file', 7 } }, + kind = 'wmsg', + }, + }, + } -- kind=wmsg ('wrapscan' after search reaches EOF) feed('uG$/i') - screen:expect{grid=[[ + screen:expect { + grid = [[ l^ine 1 | line 2 | {1:~ }|*3 - ]], attr_ids={ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {bold = true}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {foreground = Screen.colors.Blue1}, - [6] = {bold = true, reverse = true}, - [7] = {foreground = Screen.colors.Red}, - }, messages={ { - content = { { "search hit BOTTOM, continuing at TOP", 7 } }, - kind = "wmsg" - } }} + ]], + attr_ids = { + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { foreground = Screen.colors.Blue1 }, + [6] = { bold = true, reverse = true }, + [7] = { foreground = Screen.colors.Red }, + }, + messages = { + { + content = { { 'search hit BOTTOM, continuing at TOP', 7 } }, + kind = 'wmsg', + }, + }, + } -- kind=emsg after :throw feed(':throw "foo"') - screen:expect{grid=[[ + screen:expect { + grid = [[ l^ine 1 | line 2 | {1:~ }|*3 - ]], messages={ { - content = { { "Error detected while processing :", 2 } }, - kind = "emsg" - }, { - content = { { "E605: Exception not caught: foo", 2 } }, - kind = "" - }, { - content = { { "Press ENTER or type command to continue", 4 } }, - kind = "return_prompt" - } } + ]], + messages = { + { + content = { { 'Error detected while processing :', 2 } }, + kind = 'emsg', + }, + { + content = { { 'E605: Exception not caught: foo', 2 } }, + kind = '', + }, + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, } -- kind=quickfix after :cnext feed('') command("caddexpr [expand('%').':1:line1',expand('%').':2:line2']") feed(':cnext') - screen:expect{grid=[[ + screen:expect { + grid = [[ line 1 | ^line 2 | {1:~ }|*3 - ]], messages={ { - content = { { "(2 of 2): line2" } }, - kind = "quickfix" - } }} + ]], + messages = { + { + content = { { '(2 of 2): line2' } }, + kind = 'quickfix', + }, + }, + } end) it(':echoerr', function() feed(':echoerr "raa"') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{"raa", 2}}, - kind = "echoerr", - }}} + ]], + messages = { { + content = { { 'raa', 2 } }, + kind = 'echoerr', + } }, + } -- cmdline in a later input cycle clears error message feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], cmdline={{ - firstc = ":", - content = {{ "" }}, - pos = 0, - }}} - + ]], + cmdline = { { + firstc = ':', + content = { { '' } }, + pos = 0, + } }, + } feed('echoerr "bork" | echoerr "fail"') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{ "bork", 2 }}, - kind = "echoerr" - }, { - content = {{ "fail", 2 }}, - kind = "echoerr" - }, { - content = {{ "Press ENTER or type command to continue", 4 }}, - kind = "return_prompt" - }}} + ]], + messages = { + { + content = { { 'bork', 2 } }, + kind = 'echoerr', + }, + { + content = { { 'fail', 2 } }, + kind = 'echoerr', + }, + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } feed(':echoerr "extrafail"') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = { { "bork", 2 } }, - kind = "echoerr" - }, { - content = { { "fail", 2 } }, - kind = "echoerr" - }, { - content = { { "extrafail", 2 } }, - kind = "echoerr" - }, { - content = { { "Press ENTER or type command to continue", 4 } }, - kind = "return_prompt" - }}} + ]], + messages = { + { + content = { { 'bork', 2 } }, + kind = 'echoerr', + }, + { + content = { { 'fail', 2 } }, + kind = 'echoerr', + }, + { + content = { { 'extrafail', 2 } }, + kind = 'echoerr', + }, + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]]} + ]], + } -- cmdline without interleaving wait/display keeps the error message feed(':echoerr "problem" | let x = input("foo> ")') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{ "problem", 2 }}, - kind = "echoerr" - }}, cmdline={{ - prompt = "foo> ", - content = {{ "" }}, - pos = 0, - }}} + ]], + messages = { { + content = { { 'problem', 2 } }, + kind = 'echoerr', + } }, + cmdline = { + { + prompt = 'foo> ', + content = { { '' } }, + pos = 0, + }, + }, + } feed('solution') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]]} + ]], + } eq('solution', eval('x')) - feed(":messages") - screen:expect{grid=[[ + feed(':messages') + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], msg_history={ - {kind="echoerr", content={{"raa", 2}}}, - {kind="echoerr", content={{"bork", 2}}}, - {kind="echoerr", content={{"fail", 2}}}, - {kind="echoerr", content={{"extrafail", 2}}}, - {kind="echoerr", content={{"problem", 2}}} - }, messages={{ - content = {{ "Press ENTER or type command to continue", 4 }}, - kind = "return_prompt" - }}} + ]], + msg_history = { + { kind = 'echoerr', content = { { 'raa', 2 } } }, + { kind = 'echoerr', content = { { 'bork', 2 } } }, + { kind = 'echoerr', content = { { 'fail', 2 } } }, + { kind = 'echoerr', content = { { 'extrafail', 2 } } }, + { kind = 'echoerr', content = { { 'problem', 2 } } }, + }, + messages = { + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } feed '' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]]} + ]], + } end) it(':echoerr multiline', function() exec_lua([[vim.g.multi = table.concat({ "bork", "fail" }, "\n")]]) feed(':echoerr g:multi') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{ "bork\nfail", 2 }}, - kind = "echoerr" - }}} + ]], + messages = { { + content = { { 'bork\nfail', 2 } }, + kind = 'echoerr', + } }, + } feed(':messages') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{ "Press ENTER or type command to continue", 4 }}, - kind = "return_prompt" - }}, msg_history={{ - content = {{ "bork\nfail", 2 }}, - kind = "echoerr" - }}} + ]], + messages = { + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + msg_history = { + { + content = { { 'bork\nfail', 2 } }, + kind = 'echoerr', + }, + }, + } end) it('shortmess-=S', function() @@ -315,151 +411,213 @@ describe('ui/ext_messages', function() feed('iline 1\nline 2') feed('/line') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:^line} 1 | {7:line} 2 | {1:~ }|*3 - ]], messages={ - {content = {{"/line W [1/2]"}}, kind = "search_count"} - }} + ]], + messages = { + { content = { { '/line W [1/2]' } }, kind = 'search_count' }, + }, + } feed('n') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:line} 1 | {7:^line} 2 | {1:~ }|*3 - ]], messages={ - {content = {{"/line [2/2]"}}, kind = "search_count"} - }} + ]], + messages = { + { content = { { '/line [2/2]' } }, kind = 'search_count' }, + }, + } end) it(':hi Group output', function() feed(':hi ErrorMsg') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={ - {content = {{"\nErrorMsg " }, {"xxx", 2}, {" "}, - {"ctermfg=", 5 }, { "15 " }, { "ctermbg=", 5 }, { "1 " }, - {"guifg=", 5 }, { "White " }, { "guibg=", 5 }, { "Red" }}, - kind = ""} - }} + ]], + messages = { + { + content = { + { '\nErrorMsg ' }, + { 'xxx', 2 }, + { ' ' }, + { 'ctermfg=', 5 }, + { '15 ' }, + { 'ctermbg=', 5 }, + { '1 ' }, + { 'guifg=', 5 }, + { 'White ' }, + { 'guibg=', 5 }, + { 'Red' }, + }, + kind = '', + }, + }, + } end) it("doesn't crash with column adjustment #10069", function() feed(':let [x,y] = [1,2]') feed(':let x y') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={ - {content = {{ "x #1" }}, kind = ""}, - {content = {{ "y #2" }}, kind = ""}, - {content = {{ "Press ENTER or type command to continue", 4 }}, kind = "return_prompt"} - }} + ]], + messages = { + { content = { { 'x #1' } }, kind = '' }, + { content = { { 'y #2' } }, kind = '' }, + { content = { { 'Press ENTER or type command to continue', 4 } }, kind = 'return_prompt' }, + }, + } end) it('&showmode', function() command('imap echomsg "stuff"') feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={{"-- INSERT --", 3}}} + ]], + showmode = { { '-- INSERT --', 3 } }, + } feed('alphpabetalphanum') - screen:expect{grid=[[ + screen:expect { + grid = [[ alphpabet | alphanum | ^ | {1:~ }|*2 - ]], showmode={ { "-- INSERT --", 3 } }} + ]], + showmode = { { '-- INSERT --', 3 } }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ alphpabet | alphanum | ^ | {1:~ }|*2 - ]], showmode={ { "-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)", 3 } }} + ]], + showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)', 3 } }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ alphpabet | alphanum | alphanum^ | {1:~ }|*2 - ]], popupmenu={ - anchor = { 1, 2, 0 }, - items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, - pos = 1 - }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 1 of 2", 4 } }} + ]], + popupmenu = { + anchor = { 1, 2, 0 }, + items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } }, + pos = 1, + }, + showmode = { { '-- Keyword Local completion (^N^P) ', 3 }, { 'match 1 of 2', 4 } }, + } -- echomsg and showmode don't overwrite each other, this is the same -- as the TUI behavior with cmdheight=2 or larger. feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ alphpabet | alphanum | alphanum^ | {1:~ }|*2 - ]], popupmenu={ - anchor = { 1, 2, 0 }, - items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, - pos = 1 - }, messages={ { - content = { { "stuff" } }, - kind = "echomsg" - } }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 1 of 2", 4 } }} + ]], + popupmenu = { + anchor = { 1, 2, 0 }, + items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } }, + pos = 1, + }, + messages = { { + content = { { 'stuff' } }, + kind = 'echomsg', + } }, + showmode = { { '-- Keyword Local completion (^N^P) ', 3 }, { 'match 1 of 2', 4 } }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ alphpabet | alphanum | alphpabet^ | {1:~ }|*2 - ]], popupmenu={ - anchor = { 1, 2, 0 }, - items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, - pos = 0 - }, messages={ { - content = { { "stuff" } }, - kind = "echomsg" - } }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 2 of 2", 4 } }} - - feed(":messages") - screen:expect{grid=[[ + ]], + popupmenu = { + anchor = { 1, 2, 0 }, + items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } }, + pos = 0, + }, + messages = { { + content = { { 'stuff' } }, + kind = 'echomsg', + } }, + showmode = { { '-- Keyword Local completion (^N^P) ', 3 }, { 'match 2 of 2', 4 } }, + } + + feed(':messages') + screen:expect { + grid = [[ alphpabet | alphanum | alphpabe^t | {1:~ }|*2 - ]], msg_history={{ - content = {{ "stuff" }}, - kind = "echomsg", - }}, messages={{ - content = {{ "Press ENTER or type command to continue", 4}}, - kind = "return_prompt" - }}} + ]], + msg_history = { { + content = { { 'stuff' } }, + kind = 'echomsg', + } }, + messages = { + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } end) it('&showmode with macro-recording message', function() feed('qq') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={ { "recording @q", 3 } }} + ]], + showmode = { { 'recording @q', 3 } }, + } feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={ { "-- INSERT --recording @q", 3 } }} + ]], + showmode = { { '-- INSERT --recording @q', 3 } }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={ { "recording @q", 3 } }} + ]], + showmode = { { 'recording @q', 3 } }, + } feed('q') screen:expect([[ @@ -469,84 +627,127 @@ describe('ui/ext_messages', function() end) it('shows macro-recording message with &noshowmode', function() - command("set noshowmode") + command('set noshowmode') feed('qq') -- also check mode to avoid immediate success - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={ { "recording @q", 3 } }, mode="normal"} + ]], + showmode = { { 'recording @q', 3 } }, + mode = 'normal', + } feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={ { "recording @q", 3 } }, mode="insert"} + ]], + showmode = { { 'recording @q', 3 } }, + mode = 'insert', + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={ { "recording @q", 3 } }, mode="normal"} + ]], + showmode = { { 'recording @q', 3 } }, + mode = 'normal', + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], mode="normal"} + ]], + mode = 'normal', + } end) it('supports &showcmd and &ruler', function() command('set showcmd ruler') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], ruler={ { "0,0-1 All" } }} + ]], + ruler = { { '0,0-1 All' } }, + } feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], showmode={ { "-- INSERT --", 3 } }, ruler={ { "0,1 All" } }} + ]], + showmode = { { '-- INSERT --', 3 } }, + ruler = { { '0,1 All' } }, + } feed('abcde12345') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | 1234^5 | {1:~ }|*3 - ]], ruler={ { "2,5 All" } }} + ]], + ruler = { { '2,5 All' } }, + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | 1234^5 | {1:~ }|*3 - ]], showcmd={ { "d" } }, ruler={ { "2,5 All" } }} + ]], + showcmd = { { 'd' } }, + ruler = { { '2,5 All' } }, + } feed('^') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | ^12345 | {1:~ }|*3 - ]], ruler={ { "2,1 All" } }} + ]], + ruler = { { '2,1 All' } }, + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | ^12345 | {1:~ }|*3 - ]], showcmd={ { "d" } }, ruler={ { "2,1 All" } }} + ]], + showcmd = { { 'd' } }, + ruler = { { '2,1 All' } }, + } feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | ^12345 | {1:~ }|*3 - ]], showcmd={ { "di" } }, ruler={ { "2,1 All" } }} + ]], + showcmd = { { 'di' } }, + ruler = { { '2,1 All' } }, + } feed('w') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | ^ | {1:~ }|*3 - ]], ruler={ { "2,0-1 All" } }} + ]], + ruler = { { '2,0-1 All' } }, + } -- when ruler is part of statusline it is not externalized. -- this will be added as part of future ext_statusline support - command("set laststatus=2") + command('set laststatus=2') screen:expect([[ abcde | ^ | @@ -557,75 +758,108 @@ describe('ui/ext_messages', function() it('keeps history of message of different kinds', function() feed(':echomsg "howdy"') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{ "howdy" }}, kind = "echomsg"} - }} + ]], + messages = { { + content = { { 'howdy' } }, + kind = 'echomsg', + } }, + } -- always test a message without kind. If this one gets promoted to a -- category, add a new message without kind. feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{ "Type :qa and press to exit Nvim" }}, - kind = ""} - }} + ]], + messages = { + { + content = { { 'Type :qa and press to exit Nvim' } }, + kind = '', + }, + }, + } feed(':echoerr "bork"') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{ "bork", 2 }}, kind = "echoerr"} - }} + ]], + messages = { { + content = { { 'bork', 2 } }, + kind = 'echoerr', + } }, + } feed(':echo "xyz"') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{ "xyz" }}, kind = "echo"} - }} + ]], + messages = { { + content = { { 'xyz' } }, + kind = 'echo', + } }, + } feed(':call nosuchfunction()') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{ "E117: Unknown function: nosuchfunction", 2 }}, - kind = "emsg"} - }} + ]], + messages = { + { + content = { { 'E117: Unknown function: nosuchfunction', 2 } }, + kind = 'emsg', + }, + }, + } feed(':messages') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], msg_history={ - {kind="echomsg", content={{"howdy"}}}, - {kind="", content={{"Type :qa and press to exit Nvim"}}}, - {kind="echoerr", content={{"bork", 2}}}, - {kind="emsg", content={{"E117: Unknown function: nosuchfunction", 2}}} - }, messages={{ - content = {{ "Press ENTER or type command to continue", 4}}, - kind = "return_prompt" - }}} + ]], + msg_history = { + { kind = 'echomsg', content = { { 'howdy' } } }, + { kind = '', content = { { 'Type :qa and press to exit Nvim' } } }, + { kind = 'echoerr', content = { { 'bork', 2 } } }, + { kind = 'emsg', content = { { 'E117: Unknown function: nosuchfunction', 2 } } }, + }, + messages = { + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } end) it('implies ext_cmdline and ignores cmdheight', function() eq(0, eval('&cmdheight')) feed(':set cmdheight=1') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], cmdline={{ - content = { { "set cmdheight=1" } }, - firstc = ":", - pos = 15 } - }} + ]], + cmdline = { + { + content = { { 'set cmdheight=1' } }, + firstc = ':', + pos = 15, + }, + }, + } feed('') screen:expect([[ @@ -635,14 +869,19 @@ describe('ui/ext_messages', function() eq(0, eval('&cmdheight')) feed(':set cmdheight=0') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], cmdline={{ - content = { { "set cmdheight=0" } }, - firstc = ":", - pos = 15 } - }} + ]], + cmdline = { + { + content = { { 'set cmdheight=0' } }, + firstc = ':', + pos = 15, + }, + }, + } feed('') screen:expect([[ ^ | @@ -653,34 +892,52 @@ describe('ui/ext_messages', function() it('supports multiline messages from lua', function() feed(':lua error("such\\nmultiline\\nerror")') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{[[E5108: Error executing lua [string ":lua"]:1: such + ]], + messages = { + { + content = { + { + [[E5108: Error executing lua [string ":lua"]:1: such multiline error stack traceback: [C]: in function 'error' - [string ":lua"]:1: in main chunk]], 2}}, - kind = "lua_error", - }}} + [string ":lua"]:1: in main chunk]], + 2, + }, + }, + kind = 'lua_error', + }, + }, + } end) it('supports multiline messages from rpc', function() feed(':call rpcrequest(1, "test_method")') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={{ - content = {{"Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 2}}, - kind = "rpc_error" - }}, request_cb=function (name) - if name == "test_method" then - set_method_error("complete\nerror\n\nmessage") - end - end} + ]], + messages = { + { + content = { + { "Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 2 }, + }, + kind = 'rpc_error', + }, + }, + request_cb = function(name) + if name == 'test_method' then + set_method_error('complete\nerror\n\nmessage') + end + end, + } end) it('supports multiline messages for :map', function() @@ -690,10 +947,18 @@ stack traceback: command('nnoremap j k') feed(':map') - screen:expect{messages={{ - content = {{ "\nn Q @@\nn Y y$\nn j " }, { "*", 5 }, { " k" }}, - kind = '' - }}} + screen:expect { + messages = { + { + content = { + { '\nn Q @@\nn Y y$\nn j ' }, + { '*', 5 }, + { ' k' }, + }, + kind = '', + }, + }, + } end) it('wildmode=list', function() @@ -702,18 +967,23 @@ stack traceback: command('set wildmenu wildmode=list') feed(':set wildm') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*6 - ]], messages={{ - content = {{'wildmenu wildmode'}}, + ]], + messages = { { + content = { { 'wildmenu wildmode' } }, kind = '', - }}, - cmdline={{ - firstc = ':', - content = {{ 'set wildm' }}, - pos = 9, - }}} + } }, + cmdline = { + { + firstc = ':', + content = { { 'set wildm' } }, + pos = 9, + }, + }, + } end) it('hides prompt_for_number messages', function() @@ -721,70 +991,110 @@ stack traceback: feed('ihelllo') feed('z=') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:helllo} | {1:~ }|*3 {1:^~ }| - ]], messages={ - {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and or click with the mouse (q or empty cancels): ' } }, kind = ""} - }} + ]], + messages = { + { + content = { + { + 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and or click with the mouse (q or empty cancels): ', + }, + }, + kind = '', + }, + }, + } feed('1') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:helllo} | {1:~ }|*3 {1:^~ }| - ]], messages={ - {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and or click with the mouse (q or empty cancels): ' } }, kind = ""}, - { content = { { "1" } }, kind = "" } - }} + ]], + messages = { + { + content = { + { + 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and or click with the mouse (q or empty cancels): ', + }, + }, + kind = '', + }, + { content = { { '1' } }, kind = '' }, + }, + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^Hello | {1:~ }|*4 - ]]} + ]], + } end) it('supports nvim_echo messages with multiple attrs', function() - async_meths.echo({{'wow, ',"Search"}, {"such\n\nvery ", "ErrorMsg"}, {"color", "LineNr"}}, true, {}) - screen:expect{grid=[[ + async_meths.echo( + { { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } }, + true, + {} + ) + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={ - { content = { { "wow, ", 7 }, { "such\n\nvery ", 2 }, { "color", 10 } }, kind = "echomsg" } - }} + ]], + messages = { + { content = { { 'wow, ', 7 }, { 'such\n\nvery ', 2 }, { 'color', 10 } }, kind = 'echomsg' }, + }, + } feed ':ls' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={ - { content = { { '\n 1 %a "[No Name]" line 1' } }, kind = "" } - }} + ]], + messages = { + { content = { { '\n 1 %a "[No Name]" line 1' } }, kind = '' }, + }, + } feed ':messages' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]], messages={ - { content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" } - }, msg_history={ - { content = { { "wow, ", 7 }, { "such\n\nvery ", 2 }, { "color", 10 } }, kind = "echomsg" } - }} + ]], + messages = { + { content = { { 'Press ENTER or type command to continue', 4 } }, kind = 'return_prompt' }, + }, + msg_history = { + { content = { { 'wow, ', 7 }, { 'such\n\nvery ', 2 }, { 'color', 10 } }, kind = 'echomsg' }, + }, + } feed '' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*4 - ]]} + ]], + } end) it('does not truncate messages', function() - command('write '.. fname) - screen:expect({messages={ - {content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = "" } - }}) + command('write ' .. fname) + screen:expect({ + messages = { + { content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = '' }, + }, + }) end) end) @@ -793,26 +1103,27 @@ describe('ui/builtin messages', function() before_each(function() clear() screen = Screen.new(60, 7) - screen:attach({rgb=true, ext_popupmenu=true}) - screen:set_default_attr_ids { - [1] = {bold = true, foreground = Screen.colors.Blue1}; - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}; - [3] = {bold = true, reverse = true}; - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}; - [5] = {foreground = Screen.colors.Blue1}; - [6] = {bold = true, foreground = Screen.colors.Magenta}; - [7] = {background = Screen.colors.Grey20}; - [8] = {reverse = true}; - [9] = {background = Screen.colors.LightRed}; - [10] = {background = Screen.colors.Yellow}; - [11] = {foreground = Screen.colors.Brown}; + screen:attach({ rgb = true, ext_popupmenu = true }) + screen:set_default_attr_ids { + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true, reverse = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { foreground = Screen.colors.Blue1 }, + [6] = { bold = true, foreground = Screen.colors.Magenta }, + [7] = { background = Screen.colors.Grey20 }, + [8] = { reverse = true }, + [9] = { background = Screen.colors.LightRed }, + [10] = { background = Screen.colors.Yellow }, + [11] = { foreground = Screen.colors.Brown }, } end) it('supports multiline messages from rpc', function() feed(':call rpcrequest(1, "test_method")') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3: }| {2:Error invoking 'test_method' on channel 1:} | {2:complete} | @@ -820,15 +1131,17 @@ describe('ui/builtin messages', function() | {2:message} | {4:Press ENTER or type command to continue}^ | - ]], request_cb=function (name) - if name == "test_method" then - set_method_error("complete\nerror\n\nmessage") - end - end} + ]], + request_cb = function(name) + if name == 'test_method' then + set_method_error('complete\nerror\n\nmessage') + end + end, + } end) it(':hi Group output', function() - screen:try_resize(70,7) + screen:try_resize(70, 7) feed(':hi ErrorMsg') screen:expect([[ | @@ -840,7 +1153,7 @@ describe('ui/builtin messages', function() ]]) feed('') - screen:try_resize(30,7) + screen:try_resize(30, 7) feed(':hi ErrorMsg') screen:expect([[ :hi ErrorMsg | @@ -854,14 +1167,13 @@ describe('ui/builtin messages', function() feed('') -- screen size doesn't affect internal output #10285 - eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red', - exec_capture("hi ErrorMsg")) + eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red', exec_capture('hi ErrorMsg')) end) it(':syntax list langGroup output', function() - command("syntax on") - command("set syntax=vim") - screen:try_resize(110,7) + command('syntax on') + command('set syntax=vim') + screen:try_resize(110, 7) feed(':syntax list vimComment') screen:expect([[ {6:--- Syntax items ---} | @@ -874,7 +1186,7 @@ describe('ui/builtin messages', function() ]]) feed('') - screen:try_resize(55,7) + screen:try_resize(55, 7) feed(':syntax list vimComment') screen:expect([[ | @@ -889,12 +1201,14 @@ describe('ui/builtin messages', function() -- ignore final whitespace inside string -- luacheck: push ignore - eq([[--- Syntax items --- + eq( + [[--- Syntax items --- vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vimCommentGroup,vimCommentString match /\') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*5 message T1 | - ]]} + ]], + } feed(':call T2()') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*5 message T2 | - ]]} + ]], + } feed(':call T3()') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*5 message T3 | - ]]} + ]], + } end) it('supports ruler with laststatus=0', function() - command("set ruler laststatus=0") - screen:expect{grid=[[ + command('set ruler laststatus=0') + screen:expect { + grid = [[ ^ | {1:~ }|*5 0,0-1 All | - ]]} + ]], + } - command("hi MsgArea guibg=#333333") - screen:expect{grid=[[ + command('hi MsgArea guibg=#333333') + screen:expect { + grid = [[ ^ | {1:~ }|*5 {7: 0,0-1 All }| - ]]} + ]], + } - command("set rulerformat=%15(%c%V\\ %p%%%)") - screen:expect{grid=[[ + command('set rulerformat=%15(%c%V\\ %p%%%)') + screen:expect { + grid = [[ ^ | {1:~ }|*5 {7: 0,0-1 100% }| - ]]} + ]], + } end) it('supports echo with CRLF line separators', function() feed(':echo "line 1\\r\\nline 2"') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }|*2 {3: }| line 1 | line 2 | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } feed(':echo "abc\\rz"') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*5 zbc | - ]]} + ]], + } end) it('redraws UPD_NOT_VALID correctly after message', function() -- edge case: only one window was set UPD_NOT_VALID. Original report -- used :make, but fake it using one command to set the current -- window UPD_NOT_VALID and another to show a long message. - command("set more") + command('set more') feed(':new') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {8:[No Name] }| @@ -989,10 +1320,12 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }| {3:[No Name] }| :new | - ]]} + ]], + } feed(':set colorcolumn=10 | digraphs') - screen:expect{grid=[[ + screen:expect { + grid = [[ :set colorcolumn=10 | digraphs | NU {5:^@} 10 SH {5:^A} 1 SX {5:^B} 2 EX {5:^C} 3 | ET {5:^D} 4 EQ {5:^E} 5 AK {5:^F} 6 BL {5:^G} 7 | @@ -1000,10 +1333,12 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim FF {5:^L} 12 CR {5:^M} 13 SO {5:^N} 14 SI {5:^O} 15 | DL {5:^P} 16 D1 {5:^Q} 17 D2 {5:^R} 18 D3 {5:^S} 19 | {4:-- More --}^ | - ]]} + ]], + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {8:[No Name] }| @@ -1011,11 +1346,13 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }| {3:[No Name] }| | - ]]} + ]], + } -- edge case: just covers statusline feed(':set colorcolumn=5 | lua error("x\\n\\nx")') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string ":lua"]:1: x} | | {2:x} | @@ -1023,10 +1360,12 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {2: [C]: in function 'error'} | {2: [string ":lua"]:1: in main chunk} | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {8:[No Name] }| @@ -1034,33 +1373,43 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }| {3:[No Name] }| | - ]]} + ]], + } -- edge case: just covers lowest window line feed(':set colorcolumn=5 | lua error("x\\n\\n\\nx")') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string ":lua"]:1: x} | |*2 {2:x} | {2:stack traceback:} | {2: [C]: in function 'error'} | {4:-- More --}^ | - ]]} + ]], + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ |*2 {2:x} | {2:stack traceback:} | {2: [C]: in function 'error'} | {2: [string ":lua"]:1: in main chunk} | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } end) it('supports nvim_echo messages with multiple attrs', function() - async_meths.echo({{'wow, ',"Search"}, {"such\n\nvery ", "ErrorMsg"}, {"color", "LineNr"}}, true, {}) - screen:expect{grid=[[ + async_meths.echo( + { { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } }, + true, + {} + ) + screen:expect { + grid = [[ | {1:~ }| {3: }| @@ -1068,17 +1417,21 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim | {2:very }{11:color} | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } feed '' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*5 | - ]]} + ]], + } feed ':messages' - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| @@ -1086,12 +1439,13 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim | {2:very }{11:color} | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } end) it('prints lines in Ex mode correctly with a burst of carriage returns #19341', function() command('set number') - meths.buf_set_lines(0, 0, 0, true, {'aaa', 'bbb', 'ccc'}) + meths.buf_set_lines(0, 0, 0, true, { 'aaa', 'bbb', 'ccc' }) feed('gggQ1vi') screen:expect([[ Entering Ex mode. Type "visual" to go to Normal mode. | @@ -1127,17 +1481,21 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim endfunc ]]):format(to_block)) feed(':call PrintAndWait()') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }|*3 {3: }| aaa | bbb^ | - ]], timeout=timeout} + ]], + timeout = timeout, + } if type(to_unblock) == 'string' then feed(to_unblock) end - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| @@ -1145,7 +1503,8 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim bbb | ccc | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } end it('getchar()', function() @@ -1161,12 +1520,15 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim end) end) - it('consecutive calls to win_move_statusline() work after multiline message #21014',function() - async_meths.exec([[ + it('consecutive calls to win_move_statusline() work after multiline message #21014', function() + async_meths.exec( + [[ echo "\n" call win_move_statusline(0, -4) call win_move_statusline(0, 4) - ]], false) + ]], + false + ) screen:expect([[ | {1:~ }|*3 @@ -1210,17 +1572,17 @@ describe('ui/ext_messages', function() local screen before_each(function() - clear{args_rm={'--headless'}, args={"--cmd", "set shortmess-=I"}} + clear { args_rm = { '--headless' }, args = { '--cmd', 'set shortmess-=I' } } screen = Screen.new(80, 24) - screen:attach({rgb=true, ext_messages=true, ext_popupmenu=true}) + screen:attach({ rgb = true, ext_messages = true, ext_popupmenu = true }) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {bold = true}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {foreground = Screen.colors.Blue1}, - [6] = {reverse = true}, - [7] = {bold = true, reverse = true}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { foreground = Screen.colors.Blue1 }, + [6] = { reverse = true }, + [7] = { bold = true, reverse = true }, }) end) @@ -1246,14 +1608,15 @@ describe('ui/ext_messages', function() {1:~ }|*5 ]]) - feed("") + feed('') screen:expect([[ ^ | {1:~ }|*23 ]]) - feed(":intro") - screen:expect{grid=[[ + feed(':intro') + screen:expect { + grid = [[ ^ | |*4 {MATCH:.*}| @@ -1270,55 +1633,66 @@ describe('ui/ext_messages', function() | {MATCH:.*}|*2 |*5 - ]], messages={ - {content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" } - }} + ]], + messages = { + { content = { { 'Press ENTER or type command to continue', 4 } }, kind = 'return_prompt' }, + }, + } end) it('supports global statusline', function() - feed(":set laststatus=3") - feed(":sp") - feed(":set cmdheight") - screen:expect({grid=[[ + feed(':set laststatus=3') + feed(':sp') + feed(':set cmdheight') + screen:expect({ + grid = [[ ^ | {1:~ }|*10 ────────────────────────────────────────────────────────────────────────────────| | {1:~ }|*10 {7:[No Name] }| - ]], messages={ - {content = { { " cmdheight=0" } }, kind = "" } - }}) + ]], + messages = { + { content = { { ' cmdheight=0' } }, kind = '' }, + }, + }) - feed("+") - feed(":set laststatus") - screen:expect({grid=[[ + feed('+') + feed(':set laststatus') + screen:expect({ + grid = [[ ^ | {1:~ }|*11 ────────────────────────────────────────────────────────────────────────────────| | {1:~ }|*9 {7:[No Name] }| - ]], messages={ - {content = { { " laststatus=3" } }, kind = "" } - }}) + ]], + messages = { + { content = { { ' laststatus=3' } }, kind = '' }, + }, + }) - feed(":set mouse=a") + feed(':set mouse=a') meths.input_mouse('left', 'press', '', 0, 12, 10) poke_eventloop() meths.input_mouse('left', 'drag', '', 0, 11, 10) - feed("") - feed(":set cmdheight") - screen:expect({grid=[[ + feed('') + feed(':set cmdheight') + screen:expect({ + grid = [[ ^ | {1:~ }|*10 ────────────────────────────────────────────────────────────────────────────────| | {1:~ }|*10 {7:[No Name] }| - ]], messages={ - {content = { { " cmdheight=0" } }, kind = "" } - }}) + ]], + messages = { + { content = { { ' cmdheight=0' } }, kind = '' }, + }, + }) end) end) @@ -1326,9 +1700,9 @@ describe('ui/msg_puts_printf', function() it('output multibyte characters correctly', function() local screen local cmd = '' - local locale_dir = test_build_dir..'/share/locale/ja/LC_MESSAGES' + local locale_dir = test_build_dir .. '/share/locale/ja/LC_MESSAGES' - clear({env={LANG='ja_JP.UTF-8'}}) + clear({ env = { LANG = 'ja_JP.UTF-8' } }) screen = Screen.new(25, 5) screen:attach() @@ -1340,7 +1714,7 @@ describe('ui/msg_puts_printf', function() cmd = 'chcp 932 > NULL & ' end else - if (exc_exec('lang ja_JP.UTF-8') ~= 0) then + if exc_exec('lang ja_JP.UTF-8') ~= 0 then pending('Locale ja_JP.UTF-8 not supported', function() end) return elseif is_ci() then @@ -1350,11 +1724,13 @@ describe('ui/msg_puts_printf', function() end end - os.execute('cmake -E make_directory '..locale_dir) - os.execute('cmake -E copy '..test_build_dir..'/src/nvim/po/ja.mo '..locale_dir..'/nvim.mo') + os.execute('cmake -E make_directory ' .. locale_dir) + os.execute( + 'cmake -E copy ' .. test_build_dir .. '/src/nvim/po/ja.mo ' .. locale_dir .. '/nvim.mo' + ) - cmd = cmd..'"'..nvim_prog..'" -u NONE -i NONE -Es -V1' - command([[call termopen(']]..cmd..[[')]]) + cmd = cmd .. '"' .. nvim_prog .. '" -u NONE -i NONE -Es -V1' + command([[call termopen(']] .. cmd .. [[')]]) screen:expect([[ ^Exモードに入ります. ノー | マルモードに戻るには"visu| @@ -1363,7 +1739,7 @@ describe('ui/msg_puts_printf', function() | ]]) - os.execute('cmake -E remove_directory '..test_build_dir..'/share') + os.execute('cmake -E remove_directory ' .. test_build_dir .. '/share') end) end) @@ -1375,88 +1751,108 @@ describe('pager', function() screen = Screen.new(35, 8) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red, special=Screen.colors.Yellow}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {special = Screen.colors.Yellow}, - [6] = {special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4}, - [7] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey100}, - [8] = {foreground = Screen.colors.Gray90, background = Screen.colors.Grey100}, - [9] = {foreground = tonumber('0x00000c'), background = Screen.colors.Grey100}, - [10] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff')}, - [11] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber ('0x2b8452')}, - [12] = {bold = true, reverse = true}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { + foreground = Screen.colors.Grey100, + background = Screen.colors.Red, + special = Screen.colors.Yellow, + }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { special = Screen.colors.Yellow }, + [6] = { special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4 }, + [7] = { foreground = Screen.colors.Grey0, background = Screen.colors.Grey100 }, + [8] = { foreground = Screen.colors.Gray90, background = Screen.colors.Grey100 }, + [9] = { foreground = tonumber('0x00000c'), background = Screen.colors.Grey100 }, + [10] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff') }, + [11] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0x2b8452') }, + [12] = { bold = true, reverse = true }, }) - command("set more") + command('set more') - exec_lua('_G.x = ...', [[ + exec_lua( + '_G.x = ...', + [[ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud xercitation ullamco laboris nisi ut -aliquip ex ea commodo consequat.]]) +aliquip ex ea commodo consequat.]] + ) end) it('can be quit with echon', function() - screen:try_resize(25,5) + screen:try_resize(25, 5) feed(':echon join(map(range(0, &lines*10), "v:val"), "\\n")') - screen:expect{grid=[[ + screen:expect { + grid = [[ 0 | 1 | 2 | 3 | {4:-- More --}^ | - ]]} + ]], + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]]} + ]], + } end) it('can be quit with Lua #11224 #16537', function() -- NOTE: adds "4" to message history, although not displayed initially -- (triggered the more prompt). - screen:try_resize(40,5) + screen:try_resize(40, 5) feed(':lua for i=0,10 do print(i) end') - screen:expect{grid=[[ + screen:expect { + grid = [[ 0 | 1 | 2 | 3 | {4:-- More --}^ | - ]]} + ]], + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]]} + ]], + } feed(':mess') - screen:expect{grid=[[ + screen:expect { + grid = [[ 0 | 1 | 2 | 3 | {4:-- More --}^ | - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ 1 | 2 | 3 | 4 | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } feed('') end) it('handles wrapped lines with line scroll', function() feed(':lua error(_G.x)') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string }| {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | @@ -1465,10 +1861,12 @@ aliquip ex ea commodo consequat.]]) {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | {2:adipisicing elit, sed do eiusmod te}| @@ -1477,10 +1875,12 @@ aliquip ex ea commodo consequat.]]) {2:a aliqua.} | {2:Ut enim ad minim veniam, quis nostr}| {4:-- More --}^ | - ]]} + ]], + } feed('k') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string }| {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | @@ -1489,10 +1889,12 @@ aliquip ex ea commodo consequat.]]) {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | {2:adipisicing elit, sed do eiusmod te}| @@ -1501,12 +1903,14 @@ aliquip ex ea commodo consequat.]]) {2:a aliqua.} | {2:Ut enim ad minim veniam, quis nostr}| {4:-- More --}^ | - ]]} + ]], + } end) it('handles wrapped lines with page scroll', function() feed(':lua error(_G.x)') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string }| {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | @@ -1515,9 +1919,11 @@ aliquip ex ea commodo consequat.]]) {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:mpor} | {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | @@ -1526,9 +1932,11 @@ aliquip ex ea commodo consequat.]]) {2:ullamco laboris nisi ut} | {2:aliquip ex ea commodo consequat.} | {4:-- More --}^ | - ]]} + ]], + } feed('u') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string }| {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | @@ -1537,9 +1945,11 @@ aliquip ex ea commodo consequat.]]) {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:mpor} | {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | @@ -1548,14 +1958,16 @@ aliquip ex ea commodo consequat.]]) {2:ullamco laboris nisi ut} | {2:aliquip ex ea commodo consequat.} | {4:-- More --}^ | - ]]} + ]], + } end) it('handles wrapped lines with line scroll and MsgArea highlight', function() - command("hi MsgArea guisp=Yellow") + command('hi MsgArea guisp=Yellow') feed(':lua error(_G.x)') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:E5108: Error executing lua [string }| {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| @@ -1564,10 +1976,12 @@ aliquip ex ea commodo consequat.]]) {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| {3:adipisicing elit, sed do eiusmod te}| @@ -1576,10 +1990,12 @@ aliquip ex ea commodo consequat.]]) {3:a aliqua.}{5: }| {3:Ut enim ad minim veniam, quis nostr}| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('k') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:E5108: Error executing lua [string }| {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| @@ -1588,10 +2004,12 @@ aliquip ex ea commodo consequat.]]) {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| {3:adipisicing elit, sed do eiusmod te}| @@ -1600,13 +2018,15 @@ aliquip ex ea commodo consequat.]]) {3:a aliqua.}{5: }| {3:Ut enim ad minim veniam, quis nostr}| {6:-- More --}{5:^ }| - ]]} + ]], + } end) it('handles wrapped lines with page scroll and MsgArea highlight', function() - command("hi MsgArea guisp=Yellow") + command('hi MsgArea guisp=Yellow') feed(':lua error(_G.x)') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:E5108: Error executing lua [string }| {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| @@ -1615,9 +2035,11 @@ aliquip ex ea commodo consequat.]]) {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:mpor}{5: }| {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| @@ -1626,9 +2048,11 @@ aliquip ex ea commodo consequat.]]) {3:ullamco laboris nisi ut}{5: }| {3:aliquip ex ea commodo consequat.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('u') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:E5108: Error executing lua [string }| {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| @@ -1637,9 +2061,11 @@ aliquip ex ea commodo consequat.]]) {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:mpor}{5: }| {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| @@ -1648,52 +2074,60 @@ aliquip ex ea commodo consequat.]]) {3:ullamco laboris nisi ut}{5: }| {3:aliquip ex ea commodo consequat.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } end) it('preserves MsgArea highlighting after more prompt', function() - screen:try_resize(70,6) - command("hi MsgArea guisp=Yellow") - command("map x Lorem ipsum labore et dolore magna aliqua") - command("map y adipisicing elit") - command("map z incididunt ut") - command("map a labore et dolore") - command("map b ex ea commodo") - command("map xx yy") - command("map xy yz") + screen:try_resize(70, 6) + command('hi MsgArea guisp=Yellow') + command('map x Lorem ipsum labore et dolore magna aliqua') + command('map y adipisicing elit') + command('map z incididunt ut') + command('map a labore et dolore') + command('map b ex ea commodo') + command('map xx yy') + command('map xy yz') feed(':map') - screen:expect{grid=[[ + screen:expect { + grid = [[ {5: a labore et dolore }| {5: b ex ea commodo }| {5: xy yz }| {5: xx yy }| {5: x Lorem ipsum labore et dolore magna aliqua }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {5: b ex ea commodo }| {5: xy yz }| {5: xx yy }| {5: x Lorem ipsum labore et dolore magna aliqua }| {5: y adipisicing elit }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {5: xy yz }| {5: xx yy }| {5: x Lorem ipsum labore et dolore magna aliqua }| {5: y adipisicing elit }| {5: z incididunt ut }| {6:Press ENTER or type command to continue}{5:^ }| - ]]} + ]], + } end) it('clears "-- more --" message', function() - command("hi MsgArea guisp=Yellow blend=10") + command('hi MsgArea guisp=Yellow blend=10') feed(':echon join(range(20), "\\n")') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:0}{8: }| {9:1}{10: }| {9:2}{10: }| @@ -1702,10 +2136,12 @@ aliquip ex ea commodo consequat.]]) {9:5}{10: }| {9:6}{10: }| {11:--}{8: }{11:More}{8: }{11:--}{8:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:1}{8: }| {9:2}{10: }| {9:3}{10: }| @@ -1714,10 +2150,12 @@ aliquip ex ea commodo consequat.]]) {9:6}{10: }| {9:7}{10: }| {11:--}{8: }{11:More}{8: }{11:--}{8:^ }| - ]]} + ]], + } feed('k') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:0}{8: }| {9:1}{10: }| {9:2}{10: }| @@ -1726,10 +2164,12 @@ aliquip ex ea commodo consequat.]]) {9:5}{10: }| {9:6}{10: }| {11:--}{8: }{11:More}{8: }{11:--}{8:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:1}{8: }| {9:2}{10: }| {9:3}{10: }| @@ -1738,26 +2178,30 @@ aliquip ex ea commodo consequat.]]) {9:6}{10: }| {9:7}{10: }| {11:--}{8: }{11:More}{8: }{11:--}{8:^ }| - ]]} + ]], + } end) it('with :!cmd does not crash on resize', function() skip(funcs.executable('sleep') == 0, 'missing "sleep" command') feed(':!sleep 1') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }|*4 {12: }| :!sleep 1 | | - ]]} + ]], + } -- not processed while command is executing async_meths.ui_try_resize(35, 5) -- TODO(bfredl): ideally it should be processed just -- before the "press ENTER" prompt though - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }|*2 {12: }| @@ -1765,19 +2209,23 @@ aliquip ex ea commodo consequat.]]) | {4:Press ENTER or type command to cont}| {4:inue}^ | - ]]} + ]], + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*3 | - ]]} + ]], + } end) it('can be resized', function() feed(':lua error(_G.x)') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string }| {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | @@ -1786,22 +2234,26 @@ aliquip ex ea commodo consequat.]]) {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } -- responds to resize, but text is not reflown screen:try_resize(45, 5) - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:adipisicing elit, sed do eiusmod te} | {2:mpor} | {2:incididunt ut labore et dolore magn} | {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } -- can create empty space, as the command hasn't output the text below yet. -- text is not reflown; existing lines get cut screen:try_resize(30, 12) - screen:expect{grid=[[ + screen:expect { + grid = [[ :lua error(_G.x) | {2:E5108: Error executing lua [st}| {2:":lua"]:1: Lorem ipsum dolor s}| @@ -1812,12 +2264,14 @@ aliquip ex ea commodo consequat.]]) {2:a aliqua.} | |*3 {4:-- More --}^ | - ]]} + ]], + } -- continues in a mostly consistent state, but only new lines are -- wrapped at the new screen size. feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [st}| {2:":lua"]:1: Lorem ipsum dolor s}| {2:et, consectetur} | @@ -1830,10 +2284,12 @@ aliquip ex ea commodo consequat.]]) {2:ullamco laboris nisi ut} | {2:aliquip ex ea commodo consequa}| {4:-- More --}^ | - ]]} + ]], + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:":lua"]:1: Lorem ipsum dolor s}| {2:et, consectetur} | {2:adipisicing elit, sed do eiusm}| @@ -1846,20 +2302,24 @@ aliquip ex ea commodo consequat.]]) {2:aliquip ex ea commodo consequa}| {2:t.} | {4:-- More --}^ | - ]]} + ]], + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*10 | - ]]} + ]], + } end) it('with cmdheight=0 does not crash with g<', function() command('set cmdheight=0') feed(':ls') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {12: }| @@ -1868,16 +2328,20 @@ aliquip ex ea commodo consequat.]]) line 1 | {4:Press ENTER or type command to cont}| {4:inue}^ | - ]]} + ]], + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*7 - ]]} + ]], + } feed('g') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {12: }| @@ -1886,12 +2350,15 @@ aliquip ex ea commodo consequat.]]) line 1 | {4:Press ENTER or type command to cont}| {4:inue}^ | - ]]} + ]], + } feed('') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }|*7 - ]]} + ]], + } end) end) -- 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/messages_spec.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/functional/ui/messages_spec.lua') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 2a402437fd..25ae74daf1 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1445,7 +1445,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim it('prints lines in Ex mode correctly with a burst of carriage returns #19341', function() command('set number') - meths.buf_set_lines(0, 0, 0, true, { 'aaa', 'bbb', 'ccc' }) + meths.nvim_buf_set_lines(0, 0, 0, true, { 'aaa', 'bbb', 'ccc' }) feed('gggQ1vi') screen:expect([[ Entering Ex mode. Type "visual" to go to Normal mode. | @@ -1542,7 +1542,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }|*5 | ]]) - eq(1, meths.get_option_value('cmdheight', {})) + eq(1, meths.nvim_get_option_value('cmdheight', {})) end) it('using nvim_echo in VimResized does not cause hit-enter prompt #26139', function() @@ -1553,7 +1553,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }|*3 | ]]) - eq({ mode = 'n', blocking = false }, meths.get_mode()) + eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) end) end) @@ -1675,9 +1675,9 @@ describe('ui/ext_messages', function() }) feed(':set mouse=a') - meths.input_mouse('left', 'press', '', 0, 12, 10) + meths.nvim_input_mouse('left', 'press', '', 0, 12, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 11, 10) + meths.nvim_input_mouse('left', 'drag', '', 0, 11, 10) feed('') feed(':set cmdheight') screen:expect({ -- 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/messages_spec.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/functional/ui/messages_spec.lua') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 25ae74daf1..4f95cd909c 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -5,7 +5,7 @@ local eval = helpers.eval local eq = helpers.eq local command = helpers.command local set_method_error = helpers.set_method_error -local meths = helpers.meths +local api = helpers.api local async_meths = helpers.async_meths local test_build_dir = helpers.test_build_dir local nvim_prog = helpers.nvim_prog @@ -17,7 +17,7 @@ local poke_eventloop = helpers.poke_eventloop local assert_alive = helpers.assert_alive local is_os = helpers.is_os local is_ci = helpers.is_ci -local funcs = helpers.funcs +local fn = helpers.fn local skip = helpers.skip describe('ui/ext_messages', function() @@ -1445,7 +1445,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim it('prints lines in Ex mode correctly with a burst of carriage returns #19341', function() command('set number') - meths.nvim_buf_set_lines(0, 0, 0, true, { 'aaa', 'bbb', 'ccc' }) + api.nvim_buf_set_lines(0, 0, 0, true, { 'aaa', 'bbb', 'ccc' }) feed('gggQ1vi') screen:expect([[ Entering Ex mode. Type "visual" to go to Normal mode. | @@ -1542,7 +1542,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }|*5 | ]]) - eq(1, meths.nvim_get_option_value('cmdheight', {})) + eq(1, api.nvim_get_option_value('cmdheight', {})) end) it('using nvim_echo in VimResized does not cause hit-enter prompt #26139', function() @@ -1553,7 +1553,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }|*3 | ]]) - eq({ mode = 'n', blocking = false }, meths.nvim_get_mode()) + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) end) end) @@ -1675,9 +1675,9 @@ describe('ui/ext_messages', function() }) feed(':set mouse=a') - meths.nvim_input_mouse('left', 'press', '', 0, 12, 10) + api.nvim_input_mouse('left', 'press', '', 0, 12, 10) poke_eventloop() - meths.nvim_input_mouse('left', 'drag', '', 0, 11, 10) + api.nvim_input_mouse('left', 'drag', '', 0, 11, 10) feed('') feed(':set cmdheight') screen:expect({ @@ -2183,7 +2183,7 @@ aliquip ex ea commodo consequat.]] end) it('with :!cmd does not crash on resize', function() - skip(funcs.executable('sleep') == 0, 'missing "sleep" command') + skip(fn.executable('sleep') == 0, 'missing "sleep" command') feed(':!sleep 1') screen:expect { grid = [[ -- cgit From b536e0ba37addaea5507b054120e4c1e122c4405 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 15 Jan 2024 16:10:51 +0000 Subject: test: big cleanup followup Followup to 07a7c0ec --- test/functional/ui/messages_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/ui/messages_spec.lua') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 4f95cd909c..a742f765a9 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1039,7 +1039,7 @@ stack traceback: end) it('supports nvim_echo messages with multiple attrs', function() - async_meths.echo( + async_meths.nvim_echo( { { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } }, true, {} @@ -1403,7 +1403,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim end) it('supports nvim_echo messages with multiple attrs', function() - async_meths.echo( + async_meths.nvim_echo( { { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } }, true, {} @@ -1521,7 +1521,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim end) it('consecutive calls to win_move_statusline() work after multiline message #21014', function() - async_meths.exec( + async_meths.nvim_exec( [[ echo "\n" call win_move_statusline(0, -4) @@ -2196,7 +2196,7 @@ aliquip ex ea commodo consequat.]] } -- not processed while command is executing - async_meths.ui_try_resize(35, 5) + async_meths.nvim_ui_try_resize(35, 5) -- TODO(bfredl): ideally it should be processed just -- before the "press ENTER" prompt though -- cgit From 96ad7e0a4aa10ba7541e9e3256f1e84cfc9037ad Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 15 Jan 2024 19:41:22 +0000 Subject: test: refactor Paths --- test/functional/ui/messages_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/messages_spec.lua') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index a742f765a9..9d1b6163d2 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -7,7 +7,7 @@ local command = helpers.command local set_method_error = helpers.set_method_error local api = helpers.api local async_meths = helpers.async_meths -local test_build_dir = helpers.test_build_dir +local test_build_dir = helpers.paths.test_build_dir local nvim_prog = helpers.nvim_prog local exec = helpers.exec local exec_capture = helpers.exec_capture -- cgit From ca258db15668242c50a0529111398f53e4e01619 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 11 Feb 2024 18:12:56 +0800 Subject: fix(messages): clear new lines when increasing 'cmdheight' (#27421) --- test/functional/ui/messages_spec.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/functional/ui/messages_spec.lua') diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 9d1b6163d2..31b1464589 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1555,6 +1555,23 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim ]]) eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) end) + + it('bottom of screen is cleared after increasing &cmdheight #20360', function() + command('set laststatus=2') + screen:expect([[ + ^ | + {1:~ }|*4 + {3:[No Name] }| + | + ]]) + command('set cmdheight=4') + screen:expect([[ + ^ | + {1:~ }| + {3:[No Name] }| + |*4 + ]]) + end) end) it('calling screenstring() after redrawing between messages without UI #20999', function() -- cgit