From 9b9f8dfcc41ceb80d3970eb58af8ee350b57dc7f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 18 Feb 2023 09:27:10 +0800 Subject: test: make {MATCH:} behave less unexpectedly in screen:expect() Include the rest of the line and allow multiple {MATCH:} patterns. --- test/functional/ui/messages_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 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 3052a74f38..212d3aee7d 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1322,7 +1322,7 @@ describe('ui/ext_messages', function() {1:~ }type :q{5:} to exit {1: }| {1:~ }type :help{5:} for help {1: }| {1:~ }| - {1:~ }type :help news{5:} to see changes in v{MATCH:%d+%.%d+}| + {1:~{MATCH: +}}type :help news{5:} to see changes in v{MATCH:%d+%.%d+}{1:{MATCH: +}}| {1:~ }| {MATCH:.*}| {MATCH:.*}| @@ -1378,7 +1378,7 @@ describe('ui/ext_messages', function() type :q{5:} to exit | type :help{5:} for help | | - type :help news{5:} to see changes in v{MATCH:%d+%.%d+}| + {MATCH: +}type :help news{5:} to see changes in v{MATCH:%d+%.%d+ +}| | {MATCH:.*}| {MATCH:.*}| -- cgit From 846a056744bf458d4376cd7638c94f7c82862046 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 9 Mar 2023 11:45:20 +0100 Subject: refactor(redraw): make cursor position redraw use the "redraw later" pattern --- test/functional/ui/messages_spec.lua | 3 +-- 1 file changed, 1 insertion(+), 2 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 212d3aee7d..db45e80dae 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -474,8 +474,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" }}} -- cgit From 3e8955094a615f2a805350050bc1703a294b1b85 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 14 Mar 2023 02:12:26 +0100 Subject: test: re-bundle cat on windows (#21255) The builtin cat was removed in 4bc9229ecbec514e9a87cfc4be88ea27a971e9a1 as it is not used during runtime but only for tests. However, it is a very small and useful utility program that we need for a lot of our tests, so there's no harm in bundling it, and it helps us avoid complicating our build system by having two versions of neovim (neovim for users and neovim for testing). Also skip tests if "grep" or "sleep" isn't available. --- test/functional/ui/messages_spec.lua | 3 +++ 1 file changed, 3 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 db45e80dae..a92b55ae5d 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -16,6 +16,8 @@ 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 @@ -1916,6 +1918,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') screen:expect{grid=[[ | -- cgit From fe9cbcb3a5c82932ecfb8f49d07e98a1fc2b31e5 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Sat, 25 Mar 2023 18:58:48 +0200 Subject: feat(api): nvim_exec2(), deprecate nvim_exec() #19032 Problem: The signature of nvim_exec() is not extensible per ":help api-contract". Solution: Introduce nvim_exec2() and deprecate nvim_exec(). --- test/functional/ui/messages_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 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 a92b55ae5d..81602ef92e 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -986,7 +986,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)) + meths.exec2("hi ErrorMsg", { output = true }).output) end) it(':syntax list langGroup output', function() @@ -1025,7 +1025,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim match /\ Date: Sun, 26 Mar 2023 10:49:32 +0800 Subject: test: use exec_capture() in more places (#22787) Problem: Using `meths.exec2("code", { output = true })` is too verbose. Solution: Use exec_capture() in more places. --- test/functional/ui/messages_spec.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 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 81602ef92e..5220f3fa89 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -10,6 +10,7 @@ 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 @@ -986,7 +987,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.exec2("hi ErrorMsg", { output = true }).output) + exec_capture("hi ErrorMsg")) end) it(':syntax list langGroup output', function() @@ -1025,7 +1026,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim match /\ Date: Tue, 11 Apr 2023 11:18:54 +0200 Subject: test: avoid name collisions with Xtest directory (#23019) --- test/functional/ui/messages_spec.lua | 9 +++++---- 1 file changed, 5 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 5220f3fa89..1a7fe26d26 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -22,6 +22,7 @@ local skip = helpers.skip describe('ui/ext_messages', function() local screen + local fname = 'Xtest_functional_ui_messages_spec' before_each(function() clear() @@ -41,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() @@ -126,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=[[ @@ -912,9 +913,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) -- cgit From 1fe1bb084d0099fc4f9bfdc11189485d0f74b75a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 19 Dec 2022 16:37:45 +0000 Subject: refactor(options): deprecate nvim[_buf|_win]_[gs]et_option Co-authored-by: zeertzjq Co-authored-by: famiu --- 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 1a7fe26d26..46a42e5beb 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1273,7 +1273,7 @@ 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) end) -- cgit From a58bb215449cee65b965b9094e9e996ddfe78315 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 5 Oct 2023 14:44:13 +0200 Subject: refactor(grid): get rid of unbatched grid_puts and grid_putchar This finalizes the long running refactor from the old TUI-focused grid implementation where text-drawing cursor was not separated from the visible cursor. Still, the pattern of setting cursor position together with updating a line was convenient. Introduce grid_line_cursor_goto() to still allow this but now being explicit about it. Only having batched drawing functions makes code involving drawing a bit longer. But it is better to be explicit, and this highlights cases where multiple small redraws can be grouped together. This was the case for most of the changed places (messages, lastline, and :intro) --- 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 46a42e5beb..8a13796c04 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1366,7 +1366,7 @@ describe('ui/ext_messages', function() feed(":intro") screen:expect{grid=[[ - | + ^ | | | | -- cgit From ebe489d8f0edbb3538a59733289d8969d1ffea22 Mon Sep 17 00:00:00 2001 From: Jongwook Choi Date: Thu, 12 Oct 2023 19:27:45 -0400 Subject: fix: allow multiline message for echoerr (#25380) PROBLEM: Currently `:echoerr` prints multi-line strings in a single line as `:echom` does (Note: `:echon` can print multi-line strings well). This makes stacktrace printed via echoerr difficult to read. Example code: try lua error("lua stacktrace") catch echoerr v:exception endtry Output: Error detected while processing a.vim[5]..a.vim: line 4: Vim(lua):E5108: Error executing lua [string ":lua"]:1: lua stacktrace^@stack traceback:^@^I[C]: in function 'error'^@^I[string ":lua"]:1: in main chunk SOLUTION: Allow echoerr to print multiline messages (e.g., lua exceptions), because this command is usually used to print stacktraces. Output after the fix: Error detected while processing a.vim[5]..a.vim: line 4: Vim(lua):E5108: Error executing lua [string ":lua"]:1: lua stacktrace stack traceback: [C]: in function 'error' [string ":lua"]:1: in main chunk --- test/functional/ui/messages_spec.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 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 8a13796c04..ca2bf67220 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -333,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') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ]], messages={{ + content = {{ "bork\nfail", 2 }}, + kind = "echoerr" + }}} + + feed(':messages') + 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') -- cgit From 13f55750e9bea8ec8f50550546edc64a0f0964d8 Mon Sep 17 00:00:00 2001 From: nwounkn Date: Fri, 13 Oct 2023 12:01:26 +0500 Subject: fix(ui): empty line before the next message after :silent command Problem: The next command after `silent !{cmd}` or `silent lua print('str')` prints an empty line before printing a message, because these commands set `msg_didout = true` despite not printing any messages. Solution: Set `msg_didout = true` only if `msg_silent == 0` --- test/functional/ui/messages_spec.lua | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 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 ca2bf67220..a5b2474bc5 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1061,6 +1061,53 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim -- 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()') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + message T1 | + ]]} + feed(':call T2()') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + message T2 | + ]]} + feed(':call T3()') + 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=[[ -- cgit From d5a85d737aa2a5c3a64ef0aa5b01672b7ed49c09 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 10 Nov 2023 15:24:36 +0800 Subject: fix(f_wait): flush UI before blocking (#25962) --- test/functional/ui/messages_spec.lua | 59 +++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 11 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 a5b2474bc5..215e763fd1 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1312,17 +1312,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()]]) - 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()') + 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() -- cgit From 91ef26dece6d34dbb6e1b5722ce2d3f6f7e3a6de Mon Sep 17 00:00:00 2001 From: "Bara C. Tudor" Date: Wed, 22 Nov 2023 03:50:28 +0200 Subject: fix(messages): :map output with ext_messages (#26126) --- test/functional/ui/messages_spec.lua | 13 +++++++++++++ 1 file changed, 13 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 215e763fd1..a4f13aebc2 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -834,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') + + 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) -- cgit From 55dbf5c3798cde8f9bfd36cd17dce636f6f6ea08 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Nov 2023 10:44:19 +0800 Subject: fix(messages): validate msg_grid before using msg_grid_pos (#26189) --- test/functional/ui/messages_spec.lua | 13 +++++++++++++ 1 file changed, 13 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 a4f13aebc2..1d11a12af4 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1402,6 +1402,19 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim ]]) 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) it('calling screenstring() after redrawing between messages without UI #20999', function() -- cgit