aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/cmdline_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-01-25 18:31:31 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-01-25 18:31:31 +0000
commit9243becbedbb6a1592208051f8fa2b090dcc5e7d (patch)
tree607c2a862ec3f4399b8766383f6f8e04c4aa43b4 /test/functional/ui/cmdline_spec.lua
parent9e40b6e9e1bc67f2d856adb837ee64dd0e25b717 (diff)
parent3c48d3c83fc21dbc0841f9210f04bdb073d73cd1 (diff)
downloadrneovim-usermarks.tar.gz
rneovim-usermarks.tar.bz2
rneovim-usermarks.zip
Merge remote-tracking branch 'upstream/master' into usermarksusermarks
Diffstat (limited to 'test/functional/ui/cmdline_spec.lua')
-rw-r--r--test/functional/ui/cmdline_spec.lua422
1 files changed, 338 insertions, 84 deletions
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index db13647cc6..1c9ac7f7ba 100644
--- a/test/functional/ui/cmdline_spec.lua
+++ b/test/functional/ui/cmdline_spec.lua
@@ -4,9 +4,12 @@ local clear, feed = helpers.clear, helpers.feed
local source = helpers.source
local command = helpers.command
local assert_alive = helpers.assert_alive
-local uname = helpers.uname
+local poke_eventloop = helpers.poke_eventloop
+local exec = helpers.exec
local eval = helpers.eval
local eq = helpers.eq
+local is_os = helpers.is_os
+local meths = helpers.meths
local function new_screen(opt)
local screen = Screen.new(25, 5)
@@ -716,7 +719,7 @@ describe('cmdline redraw', function()
end)
it('with <Cmd>', function()
- if string.find(uname(), 'bsd') then
+ if is_os('bsd') then
pending('FIXME #10804')
end
command('cmap a <Cmd>call sin(0)<CR>') -- no-op
@@ -821,16 +824,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 +853,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 +871,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 +889,10 @@ describe('statusline is redrawn on entering cmdline', function()
feed('<cr>')
screen:expect{grid=[[
+ {9:n3 }|
^ |
+ {3:n3 }|
+ |
{1:~ }|
{1:~ }|
{1:~ }|
@@ -875,7 +900,8 @@ describe('statusline is redrawn on entering cmdline', function()
{1:~ }|
{1:~ }|
{1:~ }|
- {3:n }|
+ {1:~ }|
+ {2:[No Name] }|
|
]]}
end)
@@ -934,6 +960,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 +976,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 +987,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 +998,10 @@ describe('cmdheight=0', function()
command("set cmdheight=0 ruler laststatus=0")
screen:expect{grid=[[
^ |
- ~ |
- ~ |
- ~ |
- ~ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
]]}
end)
@@ -975,10 +1010,10 @@ describe('cmdheight=0', function()
feed('i')
screen:expect{grid=[[
^ |
- ~ |
- ~ |
- ~ |
- ~ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
]], showmode={}}
feed('<Esc>')
eq(0, eval('&cmdheight'))
@@ -989,10 +1024,10 @@ describe('cmdheight=0', function()
feed('i')
screen:expect{grid=[[
^ |
- ~ |
- ~ |
- ~ |
- ~ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
]], showmode={}}
feed('<Esc>')
eq(0, eval('&cmdheight'))
@@ -1003,10 +1038,10 @@ describe('cmdheight=0', function()
feed('i')
screen:expect{grid=[[
^ |
- ~ |
- ~ |
- ~ |
- -- INSERT -- |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {3:-- INSERT --} |
]]}
feed('<Esc>')
eq(1, eval('&cmdheight'))
@@ -1017,19 +1052,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 +1074,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 +1095,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 +1135,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 +1155,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 +1187,223 @@ 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)
+
+ it('no assert failure with showcmd', function()
+ command('set showcmd cmdheight=0')
+ feed('d')
+ screen:expect([[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ ]])
+ assert_alive()
+ end)
+
+ it('can only be resized to 0 if set explicitly', function()
+ command('set laststatus=2')
+ command('resize +1')
+ screen:expect([[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {2:[No Name] }|
+ |
+ ]])
+ command('set cmdheight=0')
+ command('resize -1')
+ command('resize +1')
+ screen:expect([[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2:[No Name] }|
+ ]])
+ end)
+
+ it("cannot be resized at all with external messages", function()
+ clear()
+ screen = new_screen({rgb=true, ext_messages=true})
+ command('set laststatus=2 mouse=a')
+ command('resize -1')
+ screen:expect([[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {3:[No Name] }|
+ ]])
+ meths.input_mouse('left', 'press', '', 0, 6, 10)
+ poke_eventloop()
+ meths.input_mouse('left', 'drag', '', 0, 5, 10)
+ screen:expect_unchanged()
+ end)
end)