diff options
Diffstat (limited to 'test/functional/ui/messages_spec.lua')
-rw-r--r-- | test/functional/ui/messages_spec.lua | 339 |
1 files changed, 314 insertions, 25 deletions
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index f038348253..00f126a1f2 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -12,6 +12,7 @@ local nvim_prog = helpers.nvim_prog local iswin = helpers.iswin local exc_exec = helpers.exc_exec local exec_lua = helpers.exec_lua +local poke_eventloop = helpers.poke_eventloop describe('ui/ext_messages', function() local screen @@ -30,6 +31,7 @@ describe('ui/ext_messages', function() [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() @@ -303,13 +305,25 @@ describe('ui/ext_messages', function() {1:~ }| {1:~ }| {1:~ }| - ]], messages={ + ]], 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 '<cr>' + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} end) it('shortmess-=S', function() @@ -454,11 +468,14 @@ describe('ui/ext_messages', function() alphpabe^t | {1:~ }| {1:~ }| - ]], messages={ - {kind="echomsg", content={{"stuff"}}}, - }, showmode={ - { "-- INSERT --", 3 } - }} + ]], msg_history={{ + content = {{ "stuff" }}, + kind = "echomsg", + }}, showmode={{ "-- INSERT --", 3 }}, + messages={{ + content = {{ "Press ENTER or type command to continue", 4}}, + kind = "return_prompt" + }}} end) it('&showmode with macro-recording message', function() @@ -684,12 +701,15 @@ describe('ui/ext_messages', function() {1:~ }| {1:~ }| {1:~ }| - ]], messages={ + ]], msg_history={ {kind="echomsg", content={{"howdy"}}}, {kind="", content={{"Type :qa and press <Enter> 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() @@ -717,7 +737,6 @@ describe('ui/ext_messages', function() ]]) eq(0, eval('&cmdheight')) - -- normally this would be an error feed(':set cmdheight=0') screen:expect{grid=[[ ^ | @@ -839,9 +858,53 @@ stack traceback: {1:~ }| {1:~ }| ]]} - 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=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]], messages={ + { content = { { "wow, ", 7 }, { "such\n\nvery ", 2 }, { "color", 10 } }, kind = "" } + }} + + feed ':ls<cr>' + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]], messages={ + { content = { { '\n 1 %a "[No Name]" line 1' } }, kind = "echomsg" } + }} + + feed ':messages<cr>' + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]], 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 '<cr>' + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]]} + end) end) describe('ui/builtin messages', function() @@ -850,17 +913,19 @@ describe('ui/builtin messages', 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} - }) + 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() @@ -1013,7 +1078,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim end) it('redraws NOT_VALID correctly after message', function() - -- edge case: only one window was set NOT_VALID. Orginal report + -- edge case: only one window was set NOT_VALID. Original report -- used :make, but fake it using one command to set the current -- window NOT_VALID and another to show a long message. command("set more") @@ -1096,6 +1161,88 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {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=[[ + | + {1:~ }| + {3: }| + {10:wow, }{2:such} | + | + {2:very }{11:color} | + {4:Press ENTER or type command to continue}^ | + ]]} + + feed '<cr>' + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + feed ':messages<cr>' + screen:expect{grid=[[ + | + {1:~ }| + {3: }| + {10:wow, }{2:such} | + | + {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'}) + command('set display-=msgsep') + feed('gggQ<CR><CR>1<CR><CR>vi') + screen:expect([[ + Entering Ex mode. Type "visual" to go to Normal mode. | + {11: 2 }bbb | + {11: 3 }ccc | + :1 | + {11: 1 }aaa | + {11: 2 }bbb | + :vi^ | + ]]) + feed('<CR>') + screen:expect([[ + {11: 1 }aaa | + {11: 2 }^bbb | + {11: 3 }ccc | + {11: 4 } | + {1:~ }| + {1:~ }| + | + ]]) + command('set display+=msgsep') + feed('gggQ<CR><CR>1<CR><CR>vi') + screen:expect([[ + Entering Ex mode. Type "visual" to go to Normal mode. | + {11: 2 }bbb | + {11: 3 }ccc | + :1 | + {11: 1 }aaa | + {11: 2 }bbb | + :vi^ | + ]]) + feed('<CR>') + screen:expect([[ + {11: 1 }aaa | + {11: 2 }^bbb | + {11: 3 }ccc | + {11: 4 } | + {1:~ }| + {1:~ }| + | + ]]) + end) end) describe('ui/ext_messages', function() @@ -1111,6 +1258,8 @@ describe('ui/ext_messages', function() [3] = {bold = true}, [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, [5] = {foreground = Screen.colors.Blue1}, + [6] = {reverse = true}, + [7] = {bold = true, reverse = true}, }) end) @@ -1202,6 +1351,107 @@ describe('ui/ext_messages', function() {content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" } }} end) + + it('supports global statusline', function() + feed(":set laststatus=3<cr>") + feed(":sp<cr>") + feed(":set cmdheight<cr>") + screen:expect({grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ────────────────────────────────────────────────────────────────────────────────| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {7:[No Name] }| + ]], messages={ + {content = { { " cmdheight=0" } }, kind = "" } + }}) + + feed("<c-w>+") + feed(":set laststatus<cr>") + screen:expect({grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ────────────────────────────────────────────────────────────────────────────────| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {7:[No Name] }| + ]], messages={ + {content = { { " laststatus=3" } }, kind = "" } + }}) + + feed(":set mouse=a<cr>") + meths.input_mouse('left', 'press', '', 0, 12, 10) + poke_eventloop() + meths.input_mouse('left', 'drag', '', 0, 12, 10) + meths.input_mouse('left', 'drag', '', 0, 11, 10) + feed("<c-l>") + feed(":set cmdheight<cr>") + screen:expect({grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ────────────────────────────────────────────────────────────────────────────────| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {7:[No Name] }| + ]], messages={ + {content = { { " cmdheight=0" } }, kind = "" } + }}) + end) end) describe('ui/msg_puts_printf', function() @@ -1226,7 +1476,7 @@ describe('ui/msg_puts_printf', function() pending('Locale ja_JP.UTF-8 not supported', function() end) return elseif helpers.isCI() then - -- Fails non--Windows CI. Message catalog direcotry issue? + -- Fails non--Windows CI. Message catalog directory issue? pending('fails on unix CI', function() end) return end @@ -1281,7 +1531,7 @@ ullamco laboris nisi ut aliquip ex ea commodo consequat.]]) end) - it('can be quit', function() + it('can be quit with echon', function() screen:try_resize(25,5) feed(':echon join(map(range(0, &lines*10), "v:val"), "\\n")<cr>') screen:expect{grid=[[ @@ -1301,6 +1551,45 @@ aliquip ex ea commodo consequat.]]) ]]} 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) + feed(':lua for i=0,10 do print(i) end<cr>') + screen:expect{grid=[[ + 0 | + 1 | + 2 | + 3 | + {4:-- More --}^ | + ]]} + feed('q') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + feed(':mess<cr>') + screen:expect{grid=[[ + 0 | + 1 | + 2 | + 3 | + {4:-- More --}^ | + ]]} + feed('j') + screen:expect{grid=[[ + 1 | + 2 | + 3 | + 4 | + {4:Press ENTER or type command to continue}^ | + ]]} + feed('<cr>') + end) + it('handles wrapped lines with line scroll', function() feed(':lua error(_G.x)<cr>') screen:expect{grid=[[ |