diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:39:54 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:39:54 +0000 |
commit | 21cb7d04c387e4198ca8098a884c78b56ffcf4c2 (patch) | |
tree | 84fe5690df1551f0bb2bdfe1a13aacd29ebc1de7 /test/functional/ui/messages_spec.lua | |
parent | d9c904f85a23a496df4eb6be42aa43f007b22d50 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-colorcolchar.tar.gz rneovim-colorcolchar.tar.bz2 rneovim-colorcolchar.zip |
Merge remote-tracking branch 'upstream/master' into colorcolcharcolorcolchar
Diffstat (limited to 'test/functional/ui/messages_spec.lua')
-rw-r--r-- | test/functional/ui/messages_spec.lua | 190 |
1 files changed, 167 insertions, 23 deletions
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 3052a74f38..1d11a12af4 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -10,15 +10,19 @@ local async_meths = helpers.async_meths local test_build_dir = helpers.test_build_dir local nvim_prog = helpers.nvim_prog local exec = helpers.exec +local exec_capture = helpers.exec_capture local exc_exec = helpers.exc_exec local exec_lua = helpers.exec_lua 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 skip = helpers.skip describe('ui/ext_messages', function() local screen + local fname = 'Xtest_functional_ui_messages_spec' before_each(function() clear() @@ -38,7 +42,7 @@ describe('ui/ext_messages', function() }) end) after_each(function() - os.remove('Xtest') + os.remove(fname) end) it('msg_clear follows msg_show kind of confirm', function() @@ -123,7 +127,7 @@ describe('ui/ext_messages', function() feed('nq') -- kind=wmsg (editing readonly file) - command('write Xtest') + command('write ' .. fname) command('set readonly nohls') feed('G$x') screen:expect{grid=[[ @@ -329,6 +333,36 @@ describe('ui/ext_messages', function() ]]} end) + it(':echoerr multiline', function() + exec_lua([[vim.g.multi = table.concat({ "bork", "fail" }, "\n")]]) + feed(':echoerr g:multi<cr>') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]], messages={{ + content = {{ "bork\nfail", 2 }}, + kind = "echoerr" + }}} + + 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 = {{ "bork\nfail", 2 }}, + kind = "echoerr" + }}} + end) + it('shortmess-=S', function() command('set shortmess-=S') feed('iline 1\nline 2<esc>') @@ -474,8 +508,7 @@ describe('ui/ext_messages', function() ]], msg_history={{ content = {{ "stuff" }}, kind = "echomsg", - }}, showmode={{ "-- INSERT --", 3 }}, - messages={{ + }}, messages={{ content = {{ "Press ENTER or type command to continue", 4}}, kind = "return_prompt" }}} @@ -801,6 +834,19 @@ stack traceback: end} end) + it('supports multiline messages for :map', function() + command('mapclear') + command('nmap Y y$') + command('nmap Q @@') + command('nnoremap j k') + feed(':map<cr>') + + screen:expect{messages={{ + content = {{ "\nn Q @@\nn Y y$\nn j " }, { "*", 5 }, { " k" }}, + kind = '' + }}} + end) + it('wildmode=list', function() screen:try_resize(25, 7) screen:set_option('ext_popupmenu', false) @@ -910,9 +956,9 @@ stack traceback: end) it('does not truncate messages', function() - command('write Xtest') + command('write '.. fname) screen:expect({messages={ - {content = { { '"Xtest" [New] 0L, 0B written' } }, kind = "" } + {content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = "" } }}) end) end) @@ -985,7 +1031,7 @@ describe('ui/builtin messages', function() -- screen size doesn't affect internal output #10285 eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red', - meths.exec("hi ErrorMsg", true)) + exec_capture("hi ErrorMsg")) end) it(':syntax list langGroup output', function() @@ -1024,10 +1070,57 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim match /\<endif\s\+".*$/ms=s+5,lc=5 contains=@vimCommentGroup,vimCommentString match /\<else\s\+".*$/ms=s+4,lc=4 contains=@vimCommentGroup,vimCommentString links to Comment]], - meths.exec('syntax list vimComment', true)) + exec_capture('syntax list vimComment')) -- luacheck: pop end) + it('no empty line after :silent #12099', function() + exec([[ + func T1() + silent !echo + echo "message T1" + endfunc + func T2() + silent lua print("lua message") + echo "message T2" + endfunc + func T3() + silent call nvim_out_write("api message\n") + echo "message T3" + endfunc + ]]) + feed(':call T1()<CR>') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + message T1 | + ]]} + feed(':call T2()<CR>') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + message T2 | + ]]} + feed(':call T3()<CR>') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + message T3 | + ]]} + end) + it('supports ruler with laststatus=0', function() command("set ruler laststatus=0") screen:expect{grid=[[ @@ -1232,17 +1325,54 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim ]]) end) - it('echo messages are shown correctly when getchar() immediately follows', function() - feed([[:echo 'foo' | echo 'bar' | call getchar()<CR>]]) - screen:expect([[ - | - {1:~ }| - {1:~ }| - {1:~ }| - {3: }| - foo | - bar^ | - ]]) + describe('echo messages are shown when immediately followed by', function() + --- @param to_block string command to cause a blocking wait + --- @param to_unblock number|string number: timeout for blocking screen + --- string: keys to stop the blocking wait + local function test_flush_before_block(to_block, to_unblock) + local timeout = type(to_unblock) == 'number' and to_unblock or nil + exec(([[ + func PrintAndWait() + echon "aaa\nbbb" + %s + echon "\nccc" + endfunc + ]]):format(to_block)) + feed(':call PrintAndWait()<CR>') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {3: }| + aaa | + bbb^ | + ]], timeout=timeout} + if type(to_unblock) == 'string' then + feed(to_unblock) + end + screen:expect{grid=[[ + | + {1:~ }| + {3: }| + aaa | + bbb | + ccc | + {4:Press ENTER or type command to continue}^ | + ]]} + end + + it('getchar()', function() + test_flush_before_block([[call getchar()]], 'k') + end) + + it('wait()', function() + test_flush_before_block([[call wait(300, '0')]], 100) + end) + + it('lua vim.wait()', function() + test_flush_before_block([[lua vim.wait(300, function() end)]], 100) + end) end) it('consecutive calls to win_move_statusline() work after multiline message #21014',function() @@ -1270,7 +1400,20 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }| | ]]) - eq(1, meths.get_option('cmdheight')) + eq(1, meths.get_option_value('cmdheight', {})) + end) + + it('using nvim_echo in VimResized does not cause hit-enter prompt #26139', function() + command([[au VimResized * lua vim.api.nvim_echo({ { '123456' } }, true, {})]]) + screen:try_resize(60, 5) + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + eq({ mode = 'n', blocking = false }, meths.get_mode()) end) end) @@ -1322,7 +1465,7 @@ describe('ui/ext_messages', function() {1:~ }type :q{5:<Enter>} to exit {1: }| {1:~ }type :help{5:<Enter>} for help {1: }| {1:~ }| - {1:~ }type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+}| + {1:~{MATCH: +}}type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+}{1:{MATCH: +}}| {1:~ }| {MATCH:.*}| {MATCH:.*}| @@ -1363,7 +1506,7 @@ describe('ui/ext_messages', function() feed(":intro<cr>") screen:expect{grid=[[ - | + ^ | | | | @@ -1378,7 +1521,7 @@ describe('ui/ext_messages', function() type :q{5:<Enter>} to exit | type :help{5:<Enter>} for help | | - type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+}| + {MATCH: +}type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+ +}| | {MATCH:.*}| {MATCH:.*}| @@ -1917,6 +2060,7 @@ aliquip ex ea commodo consequat.]]) end) it('with :!cmd does not crash on resize', function() + skip(funcs.executable('sleep') == 0, 'missing "sleep" command') feed(':!sleep 1<cr>') screen:expect{grid=[[ | |