diff options
Diffstat (limited to 'test/functional/ui/cmdline_spec.lua')
-rw-r--r-- | test/functional/ui/cmdline_spec.lua | 363 |
1 files changed, 281 insertions, 82 deletions
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index db13647cc6..8003947078 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -5,6 +5,7 @@ local source = helpers.source local command = helpers.command local assert_alive = helpers.assert_alive local uname = helpers.uname +local exec = helpers.exec local eval = helpers.eval local eq = helpers.eq @@ -821,16 +822,27 @@ describe('statusline is redrawn on entering cmdline', function() ]]} end) - it('but not with scrolled messages', function() - command('set statusline=%{mode()}') - screen:try_resize(35,10) + it('with scrolled messages', function() + screen:try_resize(35,14) + exec([[ + let g:count = 0 + autocmd CmdlineEnter * let g:count += 1 + split + resize 1 + setlocal statusline=%{mode()}%{g:count} + setlocal winbar=%{mode()}%{g:count} + ]]) feed(':echoerr doesnotexist<cr>') screen:expect{grid=[[ + {9:c1 }| + | + {3:c1 }| | {1:~ }| {1:~ }| {1:~ }| {1:~ }| + {1:~ }| {3: }| {4:E121: Undefined variable: doesnotex}| {4:ist} | @@ -839,8 +851,12 @@ describe('statusline is redrawn on entering cmdline', function() ]]} feed(':echoerr doesnotexist<cr>') screen:expect{grid=[[ + {9:c2 }| + | + {3:c2 }| | {1:~ }| + {1:~ }| {3: }| {4:E121: Undefined variable: doesnotex}| {4:ist} | @@ -853,6 +869,10 @@ describe('statusline is redrawn on entering cmdline', function() feed(':echoerr doesnotexist<cr>') screen:expect{grid=[[ + {9:c3 }| + | + {3:c3 }| + {3: }| {4:E121: Undefined variable: doesnotex}| {4:ist} | {5:Press ENTER or type command to cont}| @@ -867,7 +887,11 @@ describe('statusline is redrawn on entering cmdline', function() feed('<cr>') screen:expect{grid=[[ + {9:n3 }| ^ | + {3:n3 }| + | + {1:~ }| {1:~ }| {1:~ }| {1:~ }| @@ -875,7 +899,7 @@ describe('statusline is redrawn on entering cmdline', function() {1:~ }| {1:~ }| {1:~ }| - {3:n }| + {2:[No Name] }| | ]]} end) @@ -934,6 +958,15 @@ describe('cmdheight=0', function() before_each(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}; + } screen:attach() end) @@ -941,9 +974,9 @@ describe('cmdheight=0', function() command("set cmdheight=1 noruler laststatus=2") screen:expect{grid=[[ ^ | - ~ | - ~ | - [No Name] | + {1:~ }| + {1:~ }| + {2:[No Name] }| | ]]} end) @@ -952,10 +985,10 @@ describe('cmdheight=0', function() command("set cmdheight=0 noruler laststatus=2") screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | - [No Name] | + {1:~ }| + {1:~ }| + {1:~ }| + {2:[No Name] }| ]]} end) @@ -963,10 +996,10 @@ describe('cmdheight=0', function() command("set cmdheight=0 ruler laststatus=0") screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | - ~ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| ]]} end) @@ -975,10 +1008,10 @@ describe('cmdheight=0', function() feed('i') screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | - ~ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| ]], showmode={}} feed('<Esc>') eq(0, eval('&cmdheight')) @@ -989,10 +1022,10 @@ describe('cmdheight=0', function() feed('i') screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | - ~ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| ]], showmode={}} feed('<Esc>') eq(0, eval('&cmdheight')) @@ -1003,10 +1036,10 @@ describe('cmdheight=0', function() feed('i') screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | - -- INSERT -- | + {1:~ }| + {1:~ }| + {1:~ }| + {3:-- INSERT --} | ]]} feed('<Esc>') eq(1, eval('&cmdheight')) @@ -1017,19 +1050,19 @@ describe('cmdheight=0', function() feed(':') screen:expect{grid=[[ | - ~ | - ~ | - ~ | + {1:~ }| + {1:~ }| + {1:~ }| :^ | ]]} - eq(1, eval('&cmdheight')) + eq(0, eval('&cmdheight')) feed('<cr>') screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | - ~ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| ]], showmode={}} eq(0, eval('&cmdheight')) end) @@ -1039,19 +1072,19 @@ describe('cmdheight=0', function() feed(':call input("foo >")<cr>') screen:expect{grid=[[ | - ~ | - ~ | - ~ | + {1:~ }| + {2: }| + :call input("foo >") | foo >^ | ]]} - eq(1, eval('&cmdheight')) + eq(0, eval('&cmdheight')) feed('<cr>') screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | - ~ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| ]], showmode={}} eq(0, eval('&cmdheight')) end) @@ -1060,35 +1093,35 @@ describe('cmdheight=0', function() command("set cmdheight=0 noruler laststatus=3 winbar=foo") feed(':split<CR>') screen:expect{grid=[[ - foo | - | - E36: Not enough room | - Press ENTER or type comma| - nd to continue^ | + {2: }| + :split | + {4:E36: Not enough room} | + {5:Press ENTER or type comma}| + {5:nd to continue}^ | ]]} feed('<CR>') screen:expect{grid=[[ - foo | + {3:foo }| ^ | - ~ | - ~ | - [No Name] | + {1:~ }| + {1:~ }| + {2:[No Name] }| ]]} feed(':') screen:expect{grid=[[ - foo | + {3:foo }| | - ~ | - [No Name] | + {1:~ }| + {1:~ }| :^ | ]]} feed('<Esc>') screen:expect{grid=[[ - foo | + {3:foo }| ^ | - ~ | - ~ | - [No Name] | + {1:~ }| + {1:~ }| + {2:[No Name] }| ]], showmode={}} eq(0, eval('&cmdheight')) @@ -1100,19 +1133,19 @@ describe('cmdheight=0', function() feed('qq') screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | - recording @q | - ]], showmode={}} + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} feed('q') screen:expect{grid=[[ ^ | - ~ | - ~ | - ~ | - ~ | - ]], showmode={}} + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]], unchanged=true} end) it("when substitute text", function() @@ -1120,28 +1153,28 @@ describe('cmdheight=0', function() feed('ifoo<ESC>') screen:expect{grid=[[ fo^o | - ~ | - ~ | - ~ | - [No Name] [+] | + {1:~ }| + {1:~ }| + {1:~ }| + {2:[No Name] [+] }| ]]} feed(':%s/foo/bar/gc<CR>') screen:expect{grid=[[ - foo | - ~ | - ~ | - [No Name] [+] | - replace wi...q/l/^E/^Y)?^ | + {6:foo} | + {1:~ }| + {1:~ }| + {1:~ }| + {5:replace wi...q/l/^E/^Y)?}^ | ]]} feed('y') screen:expect{grid=[[ ^bar | - ~ | - ~ | - ~ | - [No Name] [+] | + {1:~ }| + {1:~ }| + {1:~ }| + {2:[No Name] [+] }| ]]} assert_alive() @@ -1152,4 +1185,170 @@ describe('cmdheight=0', function() feed('<C-w>+') eq(0, eval('&cmdheight')) end) + + it("with non-silent mappings with cmdline", function() + command("set cmdheight=0") + command("map <f3> :nohlsearch<cr>") + feed('iaabbaa<esc>/aa<cr>') + screen:expect{grid=[[ + {7:^aa}bb{7:aa} | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + + feed('<f3>') + screen:expect{grid=[[ + ^aabbaa | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + end) + + it('with silent! at startup', function() + 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=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + end) + + it('with multigrid', function() + clear{args={'--cmd', 'set cmdheight=0'}} + screen:attach{ext_multigrid=true} + screen:expect{grid=[[ + ## grid 1 + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + ## grid 2 + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + }} + + feed '/p' + screen:expect{grid=[[ + ## grid 1 + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [3:-------------------------]| + ## grid 2 + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + /p^ | + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1}; + }} + end) + + it('winbar is redrawn on entering cmdline and :redrawstatus #20336', function() + exec([[ + set cmdheight=0 + set winbar=%{mode()}%=:%{getcmdline()} + ]]) + feed(':') + screen:expect([[ + {3:c :}| + | + {1:~ }| + {1:~ }| + :^ | + ]]) + feed('echo') + -- not redrawn yet + screen:expect([[ + {3:c :}| + | + {1:~ }| + {1:~ }| + :echo^ | + ]]) + command('redrawstatus') + screen:expect([[ + {3:c :echo}| + | + {1:~ }| + {1:~ }| + :echo^ | + ]]) + end) + + it('window equalization with laststatus=0 #20367', function() + screen:try_resize(60, 9) + command('set cmdheight=0 laststatus=0') + command('vsplit') + screen:expect([[ + ^ │ | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + ]]) + feed(':') + command('split') + feed('<Esc>') + screen:expect([[ + ^ │ | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {2:[No Name] }│{1:~ }| + │{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + ]]) + command('resize 2') + screen:expect([[ + ^ │ | + {1:~ }│{1:~ }| + {2:[No Name] }│{1:~ }| + │{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + ]]) + feed(':') + command('wincmd =') + feed('<Esc>') + screen:expect([[ + ^ │ | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {2:[No Name] }│{1:~ }| + │{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + ]]) + end) end) |