diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-11-25 19:15:05 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-11-25 19:27:38 +0000 |
commit | c5d770d311841ea5230426cc4c868e8db27300a8 (patch) | |
tree | dd21f70127b4b8b5f109baefc8ecc5016f507c91 /test/functional/ui/messages_spec.lua | |
parent | 9be89f131f87608f224f0ee06d199fcd09d32176 (diff) | |
parent | 081beb3659bd6d8efc3e977a160b1e72becbd8a2 (diff) | |
download | rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.gz rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.bz2 rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.zip |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/functional/ui/messages_spec.lua')
-rw-r--r-- | test/functional/ui/messages_spec.lua | 216 |
1 files changed, 127 insertions, 89 deletions
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index a3e5068e55..734877d262 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -30,8 +30,7 @@ describe('ui/ext_messages', function() before_each(function() clear() - screen = Screen.new(25, 5) - screen:attach({ rgb = true, ext_messages = true, ext_popupmenu = true }) + screen = Screen.new(25, 5, { rgb = true, ext_messages = true, ext_popupmenu = true }) screen:add_extra_attr_ids { [100] = { undercurl = true, special = Screen.colors.Red }, } @@ -50,7 +49,7 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { '\ntest\n[O]k: ', 6 } }, + content = { { '\ntest\n[O]k: ', 6, 11 } }, kind = 'confirm', }, }, @@ -78,7 +77,7 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { '\ntest\n[O]k: ', 6 } }, + content = { { '\ntest\n[O]k: ', 6, 11 } }, kind = 'confirm', }, }, @@ -92,7 +91,7 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { '\ntest\n[O]k: ', 6 } }, + content = { { '\ntest\n[O]k: ', 6, 11 } }, kind = 'confirm', }, { @@ -100,7 +99,7 @@ describe('ui/ext_messages', function() kind = 'echo', }, { - content = { { 'Press ENTER or type command to continue', 6 } }, + content = { { 'Press ENTER or type command to continue', 6, 19 } }, kind = 'return_prompt', }, }, @@ -117,7 +116,7 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { 'replace with X (y/n/a/q/l/^E/^Y)?', 6 } }, + content = { { 'replace with X (y/n/a/q/l/^E/^Y)?', 6, 19 } }, kind = 'confirm_sub', }, }, @@ -136,7 +135,7 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { 'W10: Warning: Changing a readonly file', 19 } }, + content = { { 'W10: Warning: Changing a readonly file', 19, 27 } }, kind = 'wmsg', }, }, @@ -152,7 +151,7 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { 'search hit BOTTOM, continuing at TOP', 19 } }, + content = { { 'search hit BOTTOM, continuing at TOP', 19, 27 } }, kind = 'wmsg', }, }, @@ -168,15 +167,15 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { 'Error detected while processing :', 9 } }, + content = { { 'Error detected while processing :', 9, 7 } }, kind = 'emsg', }, { - content = { { 'E605: Exception not caught: foo', 9 } }, + content = { { 'E605: Exception not caught: foo', 9, 7 } }, kind = '', }, { - content = { { 'Press ENTER or type command to continue', 6 } }, + content = { { 'Press ENTER or type command to continue', 6, 19 } }, kind = 'return_prompt', }, }, @@ -209,7 +208,7 @@ describe('ui/ext_messages', function() {1:~ }|*4 ]], messages = { { - content = { { 'raa', 9 } }, + content = { { 'raa', 9, 7 } }, kind = 'echoerr', } }, } @@ -236,15 +235,15 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { 'bork', 9 } }, + content = { { 'bork', 9, 7 } }, kind = 'echoerr', }, { - content = { { 'fail', 9 } }, + content = { { 'fail', 9, 7 } }, kind = 'echoerr', }, { - content = { { 'Press ENTER or type command to continue', 6 } }, + content = { { 'Press ENTER or type command to continue', 6, 19 } }, kind = 'return_prompt', }, }, @@ -258,19 +257,19 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { 'bork', 9 } }, + content = { { 'bork', 9, 7 } }, kind = 'echoerr', }, { - content = { { 'fail', 9 } }, + content = { { 'fail', 9, 7 } }, kind = 'echoerr', }, { - content = { { 'extrafail', 9 } }, + content = { { 'extrafail', 9, 7 } }, kind = 'echoerr', }, { - content = { { 'Press ENTER or type command to continue', 6 } }, + content = { { 'Press ENTER or type command to continue', 6, 19 } }, kind = 'return_prompt', }, }, @@ -292,7 +291,7 @@ describe('ui/ext_messages', function() {1:~ }|*4 ]], messages = { { - content = { { 'problem', 9 } }, + content = { { 'problem', 9, 7 } }, kind = 'echoerr', } }, cmdline = { @@ -320,15 +319,15 @@ describe('ui/ext_messages', function() {1:~ }|*4 ]], msg_history = { - { kind = 'echoerr', content = { { 'raa', 9 } } }, - { kind = 'echoerr', content = { { 'bork', 9 } } }, - { kind = 'echoerr', content = { { 'fail', 9 } } }, - { kind = 'echoerr', content = { { 'extrafail', 9 } } }, - { kind = 'echoerr', content = { { 'problem', 9 } } }, + { kind = 'echoerr', content = { { 'raa', 9, 7 } } }, + { kind = 'echoerr', content = { { 'bork', 9, 7 } } }, + { kind = 'echoerr', content = { { 'fail', 9, 7 } } }, + { kind = 'echoerr', content = { { 'extrafail', 9, 7 } } }, + { kind = 'echoerr', content = { { 'problem', 9, 7 } } }, }, messages = { { - content = { { 'Press ENTER or type command to continue', 6 } }, + content = { { 'Press ENTER or type command to continue', 6, 19 } }, kind = 'return_prompt', }, }, @@ -351,10 +350,12 @@ describe('ui/ext_messages', function() ^ | {1:~ }|*4 ]], - messages = { { - content = { { 'bork\nfail', 9 } }, - kind = 'echoerr', - } }, + messages = { + { + content = { { 'bork\nfail', 9, 7 } }, + kind = 'echoerr', + }, + }, } feed(':messages<cr>') @@ -365,13 +366,13 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { 'Press ENTER or type command to continue', 6 } }, + content = { { 'Press ENTER or type command to continue', 6, 19 } }, kind = 'return_prompt', }, }, msg_history = { { - content = { { 'bork\nfail', 9 } }, + content = { { 'bork\nfail', 9, 7 } }, kind = 'echoerr', }, }, @@ -418,15 +419,15 @@ describe('ui/ext_messages', function() { content = { { '\nErrorMsg ' }, - { 'xxx', 9 }, + { 'xxx', 9, 7 }, { ' ' }, - { 'ctermfg=', 18 }, + { 'ctermfg=', 18, 6 }, { '15 ' }, - { 'ctermbg=', 18 }, + { 'ctermbg=', 18, 6 }, { '1 ' }, - { 'guifg=', 18 }, + { 'guifg=', 18, 6 }, { 'White ' }, - { 'guibg=', 18 }, + { 'guibg=', 18, 6 }, { 'Red' }, }, kind = '', @@ -446,7 +447,10 @@ describe('ui/ext_messages', function() messages = { { content = { { 'x #1' } }, kind = '' }, { content = { { 'y #2' } }, kind = '' }, - { content = { { 'Press ENTER or type command to continue', 6 } }, kind = 'return_prompt' }, + { + content = { { 'Press ENTER or type command to continue', 6, 19 } }, + kind = 'return_prompt', + }, }, } end) @@ -459,7 +463,7 @@ describe('ui/ext_messages', function() ^ | {1:~ }|*4 ]], - showmode = { { '-- INSERT --', 5 } }, + showmode = { { '-- INSERT --', 5, 12 } }, } feed('alphpabet<cr>alphanum<cr>') @@ -470,7 +474,7 @@ describe('ui/ext_messages', function() ^ | {1:~ }|*2 ]], - showmode = { { '-- INSERT --', 5 } }, + showmode = { { '-- INSERT --', 5, 12 } }, } feed('<c-x>') @@ -481,7 +485,7 @@ describe('ui/ext_messages', function() ^ | {1:~ }|*2 ]], - showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)', 5 } }, + showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)', 5, 12 } }, } feed('<c-p>') @@ -497,7 +501,7 @@ describe('ui/ext_messages', function() items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } }, pos = 1, }, - showmode = { { '-- Keyword Local completion (^N^P) ', 5 }, { 'match 1 of 2', 6 } }, + showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 1 of 2', 6, 19 } }, } -- echomsg and showmode don't overwrite each other, this is the same @@ -519,7 +523,7 @@ describe('ui/ext_messages', function() content = { { 'stuff' } }, kind = 'echomsg', } }, - showmode = { { '-- Keyword Local completion (^N^P) ', 5 }, { 'match 1 of 2', 6 } }, + showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 1 of 2', 6, 19 } }, } feed('<c-p>') @@ -539,7 +543,7 @@ describe('ui/ext_messages', function() content = { { 'stuff' } }, kind = 'echomsg', } }, - showmode = { { '-- Keyword Local completion (^N^P) ', 5 }, { 'match 2 of 2', 6 } }, + showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 2 of 2', 6, 19 } }, } feed('<esc>:messages<cr>') @@ -556,7 +560,7 @@ describe('ui/ext_messages', function() } }, messages = { { - content = { { 'Press ENTER or type command to continue', 6 } }, + content = { { 'Press ENTER or type command to continue', 6, 19 } }, kind = 'return_prompt', }, }, @@ -570,7 +574,7 @@ describe('ui/ext_messages', function() ^ | {1:~ }|*4 ]], - showmode = { { 'recording @q', 5 } }, + showmode = { { 'recording @q', 5, 12 } }, } feed('i') @@ -579,7 +583,7 @@ describe('ui/ext_messages', function() ^ | {1:~ }|*4 ]], - showmode = { { '-- INSERT --recording @q', 5 } }, + showmode = { { '-- INSERT --recording @q', 5, 12 } }, } feed('<esc>') @@ -588,7 +592,7 @@ describe('ui/ext_messages', function() ^ | {1:~ }|*4 ]], - showmode = { { 'recording @q', 5 } }, + showmode = { { 'recording @q', 5, 12 } }, } feed('q') @@ -607,7 +611,7 @@ describe('ui/ext_messages', function() ^ | {1:~ }|*4 ]], - showmode = { { 'recording @q', 5 } }, + showmode = { { 'recording @q', 5, 12 } }, mode = 'normal', } @@ -617,7 +621,7 @@ describe('ui/ext_messages', function() ^ | {1:~ }|*4 ]], - showmode = { { 'recording @q', 5 } }, + showmode = { { 'recording @q', 5, 12 } }, mode = 'insert', } @@ -627,7 +631,7 @@ describe('ui/ext_messages', function() ^ | {1:~ }|*4 ]], - showmode = { { 'recording @q', 5 } }, + showmode = { { 'recording @q', 5, 12 } }, mode = 'normal', } @@ -643,20 +647,22 @@ describe('ui/ext_messages', function() it('supports &showcmd and &ruler', function() command('set showcmd ruler') - screen:expect { + command('hi link MsgArea ErrorMsg') + screen:expect({ grid = [[ - ^ | - {1:~ }|*4 - ]], - ruler = { { '0,0-1 All' } }, - } + ^ | + {1:~ }|*4 + ]], + ruler = { { '0,0-1 All', 9, 62 } }, + }) + command('hi clear MsgArea') feed('i') screen:expect { grid = [[ ^ | {1:~ }|*4 ]], - showmode = { { '-- INSERT --', 5 } }, + showmode = { { '-- INSERT --', 5, 12 } }, ruler = { { '0,1 All' } }, } feed('abcde<cr>12345<esc>') @@ -694,7 +700,7 @@ describe('ui/ext_messages', function() {17:123}45 | {1:~ }|*3 ]], - showmode = { { '-- VISUAL BLOCK --', 5 } }, + showmode = { { '-- VISUAL BLOCK --', 5, 12 } }, showcmd = { { '2x3' } }, ruler = { { '1,3 All' } }, }) @@ -775,7 +781,7 @@ describe('ui/ext_messages', function() {1:~ }|*4 ]], messages = { { - content = { { 'bork', 9 } }, + content = { { 'bork', 9, 7 } }, kind = 'echoerr', } }, } @@ -800,7 +806,7 @@ describe('ui/ext_messages', function() ]], messages = { { - content = { { 'E117: Unknown function: nosuchfunction', 9 } }, + content = { { 'E117: Unknown function: nosuchfunction', 9, 7 } }, kind = 'emsg', }, }, @@ -815,12 +821,12 @@ describe('ui/ext_messages', function() msg_history = { { kind = 'echomsg', content = { { 'howdy' } } }, { kind = '', content = { { 'Type :qa and press <Enter> to exit Nvim' } } }, - { kind = 'echoerr', content = { { 'bork', 9 } } }, - { kind = 'emsg', content = { { 'E117: Unknown function: nosuchfunction', 9 } } }, + { kind = 'echoerr', content = { { 'bork', 9, 7 } } }, + { kind = 'emsg', content = { { 'E117: Unknown function: nosuchfunction', 9, 7 } } }, }, messages = { { - content = { { 'Press ENTER or type command to continue', 6 } }, + content = { { 'Press ENTER or type command to continue', 6, 19 } }, kind = 'return_prompt', }, }, @@ -893,6 +899,7 @@ stack traceback: [C]: in function 'error' [string ":lua"]:1: in main chunk]], 9, + 7, }, }, kind = 'lua_error', @@ -912,7 +919,7 @@ stack traceback: messages = { { content = { - { "Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 9 }, + { "Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 9, 7 }, }, kind = 'rpc_error', }, @@ -937,7 +944,7 @@ stack traceback: { content = { { '\nn Q @@\nn Y y$\nn j ' }, - { '*', 18 }, + { '*', 18, 1 }, { ' k' }, }, kind = '', @@ -1035,7 +1042,10 @@ stack traceback: {1:~ }|*4 ]], messages = { - { content = { { 'wow, ', 10 }, { 'such\n\nvery ', 9 }, { 'color', 8 } }, kind = 'echomsg' }, + { + content = { { 'wow, ', 10, 9 }, { 'such\n\nvery ', 9, 7 }, { 'color', 8, 13 } }, + kind = 'echomsg', + }, }, } @@ -1057,10 +1067,16 @@ stack traceback: {1:~ }|*4 ]], messages = { - { content = { { 'Press ENTER or type command to continue', 6 } }, kind = 'return_prompt' }, + { + content = { { 'Press ENTER or type command to continue', 6, 19 } }, + kind = 'return_prompt', + }, }, msg_history = { - { content = { { 'wow, ', 10 }, { 'such\n\nvery ', 9 }, { 'color', 8 } }, kind = 'echomsg' }, + { + content = { { 'wow, ', 10, 9 }, { 'such\n\nvery ', 9, 7 }, { 'color', 8, 13 } }, + kind = 'echomsg', + }, }, } @@ -1097,14 +1113,40 @@ stack traceback: }) eq(showmode, 1) end) + + it('emits single message for multiline print())', function() + exec_lua([[print("foo\nbar\nbaz")]]) + screen:expect({ + messages = { + { + content = { { 'foo\nbar\nbaz' } }, + kind = 'lua_print', + }, + }, + }) + exec_lua([[print(vim.inspect({ foo = "bar" }))]]) + screen:expect({ + grid = [[ + ^ | + {1:~ }|*4 + ]], + messages = { + { + content = { { '{\n foo = "bar"\n}' } }, + kind = 'lua_print', + }, + }, + }) + exec_lua([[vim.print({ foo = "bar" })]]) + screen:expect_unchanged() + end) end) describe('ui/builtin messages', function() local screen before_each(function() clear() - screen = Screen.new(60, 7) - screen:attach({ rgb = true, ext_popupmenu = true }) + screen = Screen.new(60, 7, { rgb = true, ext_popupmenu = true }) screen:add_extra_attr_ids { [100] = { background = Screen.colors.LightRed }, [101] = { background = Screen.colors.Grey20 }, @@ -1652,8 +1694,7 @@ describe('ui/ext_messages', function() before_each(function() clear { args_rm = { '--headless' }, args = { '--cmd', 'set shortmess-=I' } } - screen = Screen.new(80, 24) - screen:attach({ rgb = true, ext_messages = true, ext_popupmenu = true }) + screen = Screen.new(80, 24, { rgb = true, ext_messages = true, ext_popupmenu = true }) end) it('supports intro screen', function() @@ -1678,7 +1719,7 @@ describe('ui/ext_messages', function() {1:~ }type :help iccf{18:<Enter>} for information {1: }| {1:~ }|*5 ]] - local showmode = { { '-- INSERT --', 5 } } + local showmode = { { '-- INSERT --', 5, 12 } } screen:expect(introscreen) -- <c-l> (same as :mode) does _not_ clear intro message @@ -1752,7 +1793,10 @@ describe('ui/ext_messages', function() |*5 ]], messages = { - { content = { { 'Press ENTER or type command to continue', 6 } }, kind = 'return_prompt' }, + { + content = { { 'Press ENTER or type command to continue', 6, 19 } }, + kind = 'return_prompt', + }, }, } @@ -1875,8 +1919,7 @@ end) it('ui/ext_multigrid supports intro screen', function() clear { args_rm = { '--headless' }, args = { '--cmd', 'set shortmess-=I' } } - local screen = Screen.new(80, 24) - screen:attach({ rgb = true, ext_multigrid = true }) + local screen = Screen.new(80, 24, { rgb = true, ext_multigrid = true }) screen:expect { grid = [[ @@ -1951,7 +1994,6 @@ describe('ui/msg_puts_printf', function() clear({ env = { LANG = 'ja_JP.UTF-8' } }) screen = Screen.new(25, 5) - screen:attach() if is_os('win') then if os.execute('chcp 932 > NUL 2>&1') ~= 0 then @@ -1992,7 +2034,6 @@ describe('pager', function() before_each(function() clear() screen = Screen.new(35, 8) - screen:attach() screen:set_default_attr_ids({ [1] = { bold = true, foreground = Screen.colors.Blue1 }, [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, @@ -2048,8 +2089,6 @@ 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 { @@ -2079,13 +2118,13 @@ aliquip ex ea commodo consequat.]] {4:-- More --}^ | ]], } - feed('j') + feed('G') screen:expect { grid = [[ - 1 | - 2 | - 3 | - 4 | + 7 | + 8 | + 9 | + 10 | {4:Press ENTER or type command to continue}^ | ]], } @@ -2788,8 +2827,7 @@ it('pager works in headless mode with UI attached', function() end) local child_session = n.connect(child_server) - local child_screen = Screen.new(40, 6) - child_screen:attach(nil, child_session) + local child_screen = Screen.new(40, 6, nil, child_session) child_screen._default_attr_ids = nil -- TODO: unskip with new color scheme child_session:notify('nvim_command', [[echo range(100)->join("\n")]]) |