aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/messages_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /test/functional/ui/messages_spec.lua
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-rahm.tar.gz
rneovim-rahm.tar.bz2
rneovim-rahm.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'test/functional/ui/messages_spec.lua')
-rw-r--r--test/functional/ui/messages_spec.lua798
1 files changed, 584 insertions, 214 deletions
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 734877d262..5c55dfe910 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -42,104 +42,130 @@ describe('ui/ext_messages', function()
it('msg_clear follows msg_show kind of confirm', function()
feed('iline 1<esc>')
feed(':call confirm("test")<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- line ^1 |
- {1:~ }|*4
- ]],
+ line ^1 |
+ {1:~ }|*4
+ ]],
+ cmdline = {
+ {
+ content = { { '' } },
+ hl_id = 10,
+ pos = 0,
+ prompt = '[O]k: ',
+ },
+ },
messages = {
{
- content = { { '\ntest\n[O]k: ', 6, 11 } },
+ content = { { '\ntest\n', 6, 10 } },
+ history = false,
kind = 'confirm',
},
},
- }
-
+ })
feed('<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- line ^1 |
- {1:~ }|*4
- ]],
- }
+ line ^1 |
+ {1:~ }|*4
+ ]],
+ cmdline = { { abort = false } },
+ })
end)
- it('msg_show kind=confirm,confirm_sub,emsg,wmsg,quickfix', function()
+ it('msg_show kinds', function()
feed('iline 1\nline 2<esc>')
- -- kind=confirm
+ -- confirm is now cmdline prompt
feed(':echo confirm("test")<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- line 1 |
- line ^2 |
- {1:~ }|*3
- ]],
+ line 1 |
+ line ^2 |
+ {1:~ }|*3
+ ]],
+ cmdline = {
+ {
+ content = { { '' } },
+ hl_id = 10,
+ pos = 0,
+ prompt = '[O]k: ',
+ },
+ },
messages = {
{
- content = { { '\ntest\n[O]k: ', 6, 11 } },
+ content = { { '\ntest\n', 6, 10 } },
+ history = false,
kind = 'confirm',
},
},
- }
- feed('<cr><cr>')
- screen:expect {
+ })
+ feed('<cr>')
+ screen:expect({
grid = [[
- line 1 |
- line ^2 |
- {1:~ }|*3
- ]],
+ line 1 |
+ line ^2 |
+ {1:~ }|*3
+ ]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { '\ntest\n[O]k: ', 6, 11 } },
+ content = { { '\ntest\n', 6, 10 } },
+ history = false,
kind = 'confirm',
},
{
content = { { '1' } },
+ history = false,
kind = 'echo',
},
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
- }
- feed('<cr><cr>')
+ })
+ feed('<cr>')
- -- kind=confirm_sub
+ -- :substitute confirm is now cmdline prompt
feed(':%s/i/X/gc<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- l{2:i}ne 1 |
- l{10:i}ne ^2 |
- {1:~ }|*3
- ]],
- messages = {
+ l{2:^i}ne 1 |
+ l{10:i}ne 2 |
+ {1:~ }|*3
+ ]],
+ cmdline = {
{
- content = { { 'replace with X (y/n/a/q/l/^E/^Y)?', 6, 19 } },
- kind = 'confirm_sub',
+ content = { { '' } },
+ hl_id = 18,
+ pos = 0,
+ prompt = 'replace with X? (y)es/(n)o/(a)ll/(q)uit/(l)ast/scroll up(^E)/down(^Y)',
},
},
- }
+ })
feed('nq')
-- kind=wmsg (editing readonly file)
command('write ' .. fname)
command('set readonly nohls')
feed('G$x')
- screen:expect {
+ screen:expect({
grid = [[
line 1 |
- line ^2 |
+ line^ |
{1:~ }|*3
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'W10: Warning: Changing a readonly file', 19, 27 } },
+ content = { { 'W10: Warning: Changing a readonly file', 19, 26 } },
+ history = true,
kind = 'wmsg',
},
},
- }
+ })
-- kind=wmsg ('wrapscan' after search reaches EOF)
feed('uG$/i<cr>')
@@ -149,9 +175,11 @@ describe('ui/ext_messages', function()
line 2 |
{1:~ }|*3
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'search hit BOTTOM, continuing at TOP', 19, 27 } },
+ content = { { 'search hit BOTTOM, continuing at TOP', 19, 26 } },
+ history = true,
kind = 'wmsg',
},
},
@@ -160,22 +188,21 @@ describe('ui/ext_messages', function()
-- kind=emsg after :throw
feed(':throw "foo"<cr>')
screen:expect {
- grid = [[
- l^ine 1 |
- line 2 |
- {1:~ }|*3
- ]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'Error detected while processing :', 9, 7 } },
+ content = { { 'Error detected while processing :', 9, 6 } },
+ history = true,
kind = 'emsg',
},
{
- content = { { 'E605: Exception not caught: foo', 9, 7 } },
- kind = '',
+ content = { { 'E605: Exception not caught: foo', 9, 6 } },
+ history = true,
+ kind = 'emsg',
},
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -191,13 +218,213 @@ describe('ui/ext_messages', function()
^line 2 |
{1:~ }|*3
]],
+ cmdline = { { abort = false } },
messages = {
{
content = { { '(2 of 2): line2' } },
+ history = true,
kind = 'quickfix',
},
},
}
+
+ -- search_cmd
+ feed('?line<cr>')
+ screen:expect({
+ grid = [[
+ ^line 1 |
+ line 2 |
+ {1:~ }|*3
+ ]],
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { '?line ' } },
+ history = false,
+ kind = 'search_cmd',
+ },
+ },
+ })
+
+ -- highlight
+ feed(':filter character highlight<CR>')
+ screen:expect({
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = {
+ { '\n@character ' },
+ { 'xxx', 26, 155 },
+ { ' ' },
+ { 'links to', 18, 5 },
+ { ' Character\n@character.special ' },
+ { 'xxx', 16, 156 },
+ { ' ' },
+ { 'links to', 18, 5 },
+ { ' SpecialChar' },
+ },
+ history = false,
+ kind = 'list_cmd',
+ },
+ },
+ })
+
+ -- undo
+ feed('uu')
+ screen:expect({
+ grid = [[
+ ^ |
+ {1:~ }|*4
+ ]],
+ messages = {
+ {
+ content = { { 'Already at oldest change' } },
+ history = true,
+ kind = 'undo',
+ },
+ },
+ })
+
+ feed('<C-r><C-r><C-r>')
+ screen:expect({
+ grid = [[
+ line 1 |
+ line^ |
+ {1:~ }|*3
+ ]],
+ messages = {
+ {
+ content = { { 'Already at newest change' } },
+ history = true,
+ kind = 'undo',
+ },
+ },
+ })
+
+ -- kind=completion
+ command('set noshowmode')
+ feed('i<C-n>')
+ screen:expect({
+ messages = {
+ {
+ content = { { 'The only match' } },
+ history = false,
+ kind = 'completion',
+ },
+ },
+ })
+ feed('<Esc>')
+ command('set showmode')
+
+ -- kind=echoerr for nvim_echo() err
+ feed(':call nvim_echo([["Error"], ["Message", "Special"]], 1, #{ err:1 })<CR>')
+ screen:expect({
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'Error', 9, 6 }, { 'Message', 16, 99 } },
+ history = true,
+ kind = 'echoerr',
+ },
+ },
+ })
+
+ -- kind=verbose for nvim_echo() verbose
+ feed(':call nvim_echo([["Verbose Message"]], 1, #{ verbose:1 })<CR>')
+ screen:expect({
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'Verbose Message' } },
+ history = true,
+ kind = 'verbose',
+ },
+ },
+ })
+
+ -- kind=verbose for :verbose messages
+ feed(':1verbose filter Diff[AC] hi<CR>')
+ screen:expect({
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = {
+ { '\nDiffAdd ' },
+ { 'xxx', 22, 30 },
+ { ' ' },
+ { 'ctermbg=', 18, 5 },
+ { '81 ' },
+ { 'guibg=', 18, 5 },
+ { 'LightBlue' },
+ },
+ history = false,
+ kind = 'list_cmd',
+ },
+ {
+ content = { { '\n\tLast set from Lua (run Nvim with -V1 for more details)' } },
+ history = false,
+ kind = 'verbose',
+ },
+ {
+ content = {
+ { '\nDiffChange ' },
+ { 'xxx', 4, 31 },
+ { ' ' },
+ { 'ctermbg=', 18, 5 },
+ { '225 ' },
+ { 'guibg=', 18, 5 },
+ { 'LightMagenta' },
+ },
+ history = false,
+ kind = 'list_cmd',
+ },
+ {
+ content = { { '\n\tLast set from Lua (run Nvim with -V1 for more details)' } },
+ history = false,
+ kind = 'verbose',
+ },
+ {
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
+ kind = 'return_prompt',
+ },
+ },
+ })
+
+ -- kind=shell for :!cmd messages
+ local cmd = t.is_os('win') and 'echo stdout& echo stderr>&2& exit 3'
+ or '{ echo stdout; echo stderr >&2; exit 3; }'
+ feed(('<CR>:!%s<CR>'):format(cmd))
+ screen:expect({
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { (':!%s\r\n[No write since last change]\n'):format(cmd) } },
+ history = false,
+ kind = '',
+ },
+ {
+ content = { { ('stdout%s\n'):format(t.is_os('win') and '\r' or '') } },
+ history = false,
+ kind = 'shell_out',
+ },
+ {
+ content = { { ('stderr%s\n'):format(t.is_os('win') and '\r' or ''), 9, 6 } },
+ history = false,
+ kind = 'shell_err',
+ },
+ {
+ content = { { '\nshell returned 3\n\n' } },
+ history = false,
+ kind = 'shell_ret',
+ },
+ {
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
+ kind = 'return_prompt',
+ },
+ },
+ })
end)
it(':echoerr', function()
@@ -207,10 +434,14 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- messages = { {
- content = { { 'raa', 9, 7 } },
- kind = 'echoerr',
- } },
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'raa', 9, 6 } },
+ history = true,
+ kind = 'echoerr',
+ },
+ },
}
-- cmdline in a later input cycle clears error message
@@ -233,17 +464,21 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'bork', 9, 7 } },
+ content = { { 'bork', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
{
- content = { { 'fail', 9, 7 } },
+ content = { { 'fail', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -255,21 +490,26 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'bork', 9, 7 } },
+ content = { { 'bork', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
{
- content = { { 'fail', 9, 7 } },
+ content = { { 'fail', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
{
- content = { { 'extrafail', 9, 7 } },
+ content = { { 'extrafail', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -290,13 +530,17 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- messages = { {
- content = { { 'problem', 9, 7 } },
- kind = 'echoerr',
- } },
+ messages = {
+ {
+ content = { { 'problem', 9, 6 } },
+ history = true,
+ kind = 'echoerr',
+ },
+ },
cmdline = {
{
prompt = 'foo> ',
+ hl_id = 0,
content = { { '' } },
pos = 0,
},
@@ -309,6 +553,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
}
eq('solution', eval('x'))
@@ -318,16 +563,18 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
msg_history = {
- { 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 } } },
+ { kind = 'echoerr', content = { { 'raa', 9, 6 } } },
+ { kind = 'echoerr', content = { { 'bork', 9, 6 } } },
+ { kind = 'echoerr', content = { { 'fail', 9, 6 } } },
+ { kind = 'echoerr', content = { { 'extrafail', 9, 6 } } },
+ { kind = 'echoerr', content = { { 'problem', 9, 6 } } },
},
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -350,9 +597,11 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'bork\nfail', 9, 7 } },
+ content = { { 'bork\nfail', 9, 6 } },
+ history = true,
kind = 'echoerr',
},
},
@@ -364,15 +613,17 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
msg_history = {
{
- content = { { 'bork\nfail', 9, 7 } },
+ content = { { 'bork\nfail', 9, 6 } },
kind = 'echoerr',
},
},
@@ -390,8 +641,9 @@ describe('ui/ext_messages', function()
{10:line} 2 |
{1:~ }|*3
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { '/line W [1/2]' } }, kind = 'search_count' },
+ { content = { { '/line W [1/2]' } }, kind = 'search_count', history = false },
},
}
@@ -403,35 +655,7 @@ describe('ui/ext_messages', function()
{1:~ }|*3
]],
messages = {
- { content = { { '/line [2/2]' } }, kind = 'search_count' },
- },
- }
- end)
-
- it(':hi Group output', function()
- feed(':hi ErrorMsg<cr>')
- screen:expect {
- grid = [[
- ^ |
- {1:~ }|*4
- ]],
- messages = {
- {
- content = {
- { '\nErrorMsg ' },
- { 'xxx', 9, 7 },
- { ' ' },
- { 'ctermfg=', 18, 6 },
- { '15 ' },
- { 'ctermbg=', 18, 6 },
- { '1 ' },
- { 'guifg=', 18, 6 },
- { 'White ' },
- { 'guibg=', 18, 6 },
- { 'Red' },
- },
- kind = '',
- },
+ { content = { { '/line [2/2]' } }, kind = 'search_count', history = false },
},
}
end)
@@ -444,11 +668,13 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { 'x #1' } }, kind = '' },
- { content = { { 'y #2' } }, kind = '' },
+ { content = { { 'x #1' } }, kind = 'list_cmd', history = false },
+ { content = { { 'y #2' } }, kind = 'list_cmd', history = false },
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -463,7 +689,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { '-- INSERT --', 5, 12 } },
+ showmode = { { '-- INSERT --', 5, 11 } },
}
feed('alphpabet<cr>alphanum<cr>')
@@ -474,7 +700,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*2
]],
- showmode = { { '-- INSERT --', 5, 12 } },
+ showmode = { { '-- INSERT --', 5, 11 } },
}
feed('<c-x>')
@@ -485,7 +711,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*2
]],
- showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)', 5, 12 } },
+ showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)', 5, 11 } },
}
feed('<c-p>')
@@ -501,7 +727,7 @@ describe('ui/ext_messages', function()
items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } },
pos = 1,
},
- showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 1 of 2', 6, 19 } },
+ showmode = { { '-- Keyword Local completion (^N^P) ', 5, 11 }, { 'match 1 of 2', 6, 18 } },
}
-- echomsg and showmode don't overwrite each other, this is the same
@@ -519,11 +745,14 @@ describe('ui/ext_messages', function()
items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } },
pos = 1,
},
- messages = { {
- content = { { 'stuff' } },
- kind = 'echomsg',
- } },
- showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 1 of 2', 6, 19 } },
+ messages = {
+ {
+ content = { { 'stuff' } },
+ history = true,
+ kind = 'echomsg',
+ },
+ },
+ showmode = { { '-- Keyword Local completion (^N^P) ', 5, 11 }, { 'match 1 of 2', 6, 18 } },
}
feed('<c-p>')
@@ -539,11 +768,14 @@ describe('ui/ext_messages', function()
items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } },
pos = 0,
},
- messages = { {
- content = { { 'stuff' } },
- kind = 'echomsg',
- } },
- showmode = { { '-- Keyword Local completion (^N^P) ', 5, 12 }, { 'match 2 of 2', 6, 19 } },
+ messages = {
+ {
+ content = { { 'stuff' } },
+ history = true,
+ kind = 'echomsg',
+ },
+ },
+ showmode = { { '-- Keyword Local completion (^N^P) ', 5, 11 }, { 'match 2 of 2', 6, 18 } },
}
feed('<esc>:messages<cr>')
@@ -554,13 +786,15 @@ describe('ui/ext_messages', function()
alphpabe^t |
{1:~ }|*2
]],
+ cmdline = { { abort = false } },
msg_history = { {
content = { { 'stuff' } },
kind = 'echomsg',
} },
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -574,7 +808,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { 'recording @q', 5, 12 } },
+ showmode = { { 'recording @q', 5, 11 } },
}
feed('i')
@@ -583,7 +817,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { '-- INSERT --recording @q', 5, 12 } },
+ showmode = { { '-- INSERT --recording @q', 5, 11 } },
}
feed('<esc>')
@@ -592,7 +826,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { 'recording @q', 5, 12 } },
+ showmode = { { 'recording @q', 5, 11 } },
}
feed('q')
@@ -611,7 +845,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { 'recording @q', 5, 12 } },
+ showmode = { { 'recording @q', 5, 11 } },
mode = 'normal',
}
@@ -621,7 +855,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { 'recording @q', 5, 12 } },
+ showmode = { { 'recording @q', 5, 11 } },
mode = 'insert',
}
@@ -631,7 +865,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { 'recording @q', 5, 12 } },
+ showmode = { { 'recording @q', 5, 11 } },
mode = 'normal',
}
@@ -653,7 +887,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- ruler = { { '0,0-1 All', 9, 62 } },
+ ruler = { { '0,0-1 All', 9, 61 } },
})
command('hi clear MsgArea')
feed('i')
@@ -662,7 +896,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- showmode = { { '-- INSERT --', 5, 12 } },
+ showmode = { { '-- INSERT --', 5, 11 } },
ruler = { { '0,1 All' } },
}
feed('abcde<cr>12345<esc>')
@@ -700,7 +934,7 @@ describe('ui/ext_messages', function()
{17:123}45 |
{1:~ }|*3
]],
- showmode = { { '-- VISUAL BLOCK --', 5, 12 } },
+ showmode = { { '-- VISUAL BLOCK --', 5, 11 } },
showcmd = { { '2x3' } },
ruler = { { '1,3 All' } },
})
@@ -752,10 +986,14 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- messages = { {
- content = { { 'howdy' } },
- kind = 'echomsg',
- } },
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'howdy' } },
+ history = true,
+ kind = 'echomsg',
+ },
+ },
}
-- always test a message without kind. If this one gets promoted to a
@@ -769,6 +1007,7 @@ describe('ui/ext_messages', function()
messages = {
{
content = { { 'Type :qa and press <Enter> to exit Nvim' } },
+ history = true,
kind = '',
},
},
@@ -780,10 +1019,14 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- messages = { {
- content = { { 'bork', 9, 7 } },
- kind = 'echoerr',
- } },
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'bork', 9, 6 } },
+ history = true,
+ kind = 'echoerr',
+ },
+ },
}
feed(':echo "xyz"<cr>')
@@ -792,10 +1035,14 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- messages = { {
- content = { { 'xyz' } },
- kind = 'echo',
- } },
+ cmdline = { { abort = false } },
+ messages = {
+ {
+ content = { { 'xyz' } },
+ history = false,
+ kind = 'echo',
+ },
+ },
}
feed(':call nosuchfunction()<cr>')
@@ -804,9 +1051,11 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'E117: Unknown function: nosuchfunction', 9, 7 } },
+ content = { { 'E117: Unknown function: nosuchfunction', 9, 6 } },
+ history = true,
kind = 'emsg',
},
},
@@ -818,15 +1067,17 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
msg_history = {
{ kind = 'echomsg', content = { { 'howdy' } } },
{ kind = '', content = { { 'Type :qa and press <Enter> to exit Nvim' } } },
- { kind = 'echoerr', content = { { 'bork', 9, 7 } } },
- { kind = 'emsg', content = { { 'E117: Unknown function: nosuchfunction', 9, 7 } } },
+ { kind = 'echoerr', content = { { 'bork', 9, 6 } } },
+ { kind = 'emsg', content = { { 'E117: Unknown function: nosuchfunction', 9, 6 } } },
},
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -851,11 +1102,14 @@ describe('ui/ext_messages', function()
}
feed('<cr>')
- screen:expect([[
- ^ |
- {1:~ }|*3
- |
- ]])
+ screen:expect({
+ grid = [[
+ ^ |
+ {1:~ }|*3
+ |
+ ]],
+ cmdline = { { abort = false } },
+ })
eq(1, eval('&cmdheight'))
feed(':set cmdheight=0')
@@ -874,10 +1128,13 @@ describe('ui/ext_messages', function()
},
}
feed('<cr>')
- screen:expect([[
- ^ |
- {1:~ }|*4
- ]])
+ screen:expect({
+ grid = [[
+ ^ |
+ {1:~ }|*4
+ ]],
+ cmdline = { { abort = false } },
+ })
eq(0, eval('&cmdheight'))
end)
@@ -888,6 +1145,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
content = {
@@ -899,9 +1157,10 @@ stack traceback:
[C]: in function 'error'
[string ":lua"]:1: in main chunk]],
9,
- 7,
+ 6,
},
},
+ history = true,
kind = 'lua_error',
},
},
@@ -916,11 +1175,13 @@ stack traceback:
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
content = {
- { "Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 9, 7 },
+ { "Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 9, 6 },
},
+ history = true,
kind = 'rpc_error',
},
},
@@ -940,6 +1201,7 @@ stack traceback:
feed(':map<cr>')
screen:expect {
+ cmdline = { { abort = false } },
messages = {
{
content = {
@@ -947,7 +1209,8 @@ stack traceback:
{ '*', 18, 1 },
{ ' k' },
},
- kind = '',
+ history = false,
+ kind = 'list_cmd',
},
},
}
@@ -964,10 +1227,13 @@ stack traceback:
^ |
{1:~ }|*6
]],
- messages = { {
- content = { { 'wildmenu wildmode' } },
- kind = '',
- } },
+ messages = {
+ {
+ content = { { 'wildmenu wildmode\n' } },
+ history = false,
+ kind = 'wildlist',
+ },
+ },
cmdline = {
{
firstc = ':',
@@ -983,51 +1249,94 @@ stack traceback:
feed('ihelllo<esc>')
feed('z=')
- screen:expect {
+ screen:expect({
grid = [[
- {100:helllo} |
- {1:~ }|*3
- {1:^~ }|
- ]],
+ {100:^helllo} |
+ {1:~ }|*4
+ ]],
+ cmdline = {
+ {
+ content = { { '' } },
+ hl_id = 0,
+ pos = 0,
+ prompt = 'Type number and <Enter> or click with the mouse (q or empty cancels): ',
+ },
+ },
messages = {
{
- content = {
- {
- 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ',
- },
- },
- kind = '',
+ content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\n' } },
+ history = false,
+ kind = 'list_cmd',
},
},
- }
+ })
feed('1')
- screen:expect {
+ screen:expect({
grid = [[
- {100:helllo} |
- {1:~ }|*3
- {1:^~ }|
- ]],
+ {100:^helllo} |
+ {1:~ }|*4
+ ]],
+ cmdline = {
+ {
+ content = { { '1' } },
+ hl_id = 0,
+ pos = 1,
+ prompt = 'Type number and <Enter> or click with the mouse (q or empty cancels): ',
+ },
+ },
messages = {
{
- content = {
- {
- 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ',
- },
- },
- kind = '',
+ content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\n' } },
+ history = false,
+ kind = 'list_cmd',
},
- { content = { { '1' } }, kind = '' },
},
- }
+ })
feed('<cr>')
- screen:expect {
+ screen:expect({
grid = [[
- ^Hello |
- {1:~ }|*4
- ]],
- }
+ ^Hello |
+ {1:~ }|*4
+ ]],
+ cmdline = { { abort = false } },
+ })
+
+ async_meths.nvim_command("let g:n = inputlist(['input0', 'input1'])")
+ screen:expect({
+ grid = [[
+ ^Hello |
+ {1:~ }|*4
+ ]],
+ cmdline = {
+ {
+ content = { { '' } },
+ hl_id = 0,
+ pos = 0,
+ prompt = 'Type number and <Enter> or click with the mouse (q or empty cancels): ',
+ },
+ },
+ messages = {
+ {
+ content = { { 'input0\ninput1\n' } },
+ history = false,
+ kind = 'list_cmd',
+ },
+ },
+ })
+
+ feed('42<CR>')
+ screen:expect({
+ grid = [[
+ ^Hello |
+ {1:~ }|*4
+ ]],
+ cmdline = { {
+ abort = false,
+ } },
+ })
+ eq(42, eval('g:n'))
end)
it('supports nvim_echo messages with multiple attrs', function()
@@ -1043,7 +1352,8 @@ stack traceback:
]],
messages = {
{
- content = { { 'wow, ', 10, 9 }, { 'such\n\nvery ', 9, 7 }, { 'color', 8, 13 } },
+ content = { { 'wow, ', 10, 8 }, { 'such\n\nvery ', 9, 6 }, { 'color', 8, 12 } },
+ history = true,
kind = 'echomsg',
},
},
@@ -1055,8 +1365,13 @@ stack traceback:
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { '\n 1 %a "[No Name]" line 1' } }, kind = '' },
+ {
+ content = { { '\n 1 %a "[No Name]" line 1' } },
+ kind = 'list_cmd',
+ history = false,
+ },
},
}
@@ -1066,15 +1381,17 @@ stack traceback:
^ |
{1:~ }|*4
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
msg_history = {
{
- content = { { 'wow, ', 10, 9 }, { 'such\n\nvery ', 9, 7 }, { 'color', 8, 13 } },
+ content = { { 'wow, ', 10, 8 }, { 'such\n\nvery ', 9, 6 }, { 'color', 8, 12 } },
kind = 'echomsg',
},
},
@@ -1093,7 +1410,11 @@ stack traceback:
command('write ' .. fname)
screen:expect({
messages = {
- { content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = '' },
+ {
+ content = { { string.format('"%s" [New] 0L, 0B written', fname) } },
+ kind = 'bufwrite',
+ history = true,
+ },
},
})
end)
@@ -1105,13 +1426,25 @@ stack traceback:
screen_showmode(...)
showmode = showmode + 1
end
+ local s1 = [[
+ ^ |
+ {1:~ }|*4
+ ]]
+ screen:expect(s1)
+ eq(showmode, 0)
+ feed('i')
screen:expect({
- grid = [[
- ^ |
- {1:~ }|*4
- ]],
+ grid = s1,
+ showmode = { { '-- INSERT --', 5, 11 } },
})
- eq(showmode, 1)
+ eq(showmode, 2)
+ command('set noshowmode')
+ feed('<Esc>')
+ screen:expect(s1)
+ eq(showmode, 3)
+ feed('i')
+ screen:expect_unchanged()
+ eq(showmode, 3)
end)
it('emits single message for multiline print())', function()
@@ -1120,6 +1453,7 @@ stack traceback:
messages = {
{
content = { { 'foo\nbar\nbaz' } },
+ history = true,
kind = 'lua_print',
},
},
@@ -1133,6 +1467,7 @@ stack traceback:
messages = {
{
content = { { '{\n foo = "bar"\n}' } },
+ history = true,
kind = 'lua_print',
},
},
@@ -1140,6 +1475,36 @@ stack traceback:
exec_lua([[vim.print({ foo = "bar" })]])
screen:expect_unchanged()
end)
+
+ it('ruler redraw does not crash due to double grid_line_start()', function()
+ exec_lua([[
+ local ns = vim.api.nvim_create_namespace('')
+ vim.ui_attach(ns, { ext_messages = true }, function(event, ...)
+ if event == 'msg_ruler' then
+ vim.api.nvim__redraw({ flush = true })
+ end
+ end)
+ vim.o.ruler = true
+ vim.o.laststatus = 0
+ ]])
+ feed('i')
+ n.assert_alive()
+ end)
+
+ it(':digraph contains newlines', function()
+ command('digraph')
+ screen:expect({
+ condition = function()
+ local nl = 0
+ eq('list_cmd', screen.messages[1].kind)
+ for _, chunk in ipairs(screen.messages[1].content) do
+ nl = nl + (chunk[2]:find('\n') and 1 or 0)
+ end
+ eq(682, nl)
+ screen.messages = {}
+ end,
+ })
+ end)
end)
describe('ui/builtin messages', function()
@@ -1719,7 +2084,7 @@ describe('ui/ext_messages', function()
{1:~ }type :help iccf{18:<Enter>} for information {1: }|
{1:~ }|*5
]]
- local showmode = { { '-- INSERT --', 5, 12 } }
+ local showmode = { { '-- INSERT --', 5, 11 } }
screen:expect(introscreen)
-- <c-l> (same as :mode) does _not_ clear intro message
@@ -1792,9 +2157,11 @@ describe('ui/ext_messages', function()
type :help iccf{18:<Enter>} for information |
|*5
]],
+ cmdline = { { abort = false } },
messages = {
{
- content = { { 'Press ENTER or type command to continue', 6, 19 } },
+ content = { { 'Press ENTER or type command to continue', 6, 18 } },
+ history = false,
kind = 'return_prompt',
},
},
@@ -1874,8 +2241,9 @@ describe('ui/ext_messages', function()
{1:~ }|*10
{3:[No Name] }|
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { ' cmdheight=0' } }, kind = '' },
+ { content = { { ' cmdheight=0' } }, kind = 'list_cmd', history = false },
},
})
@@ -1890,8 +2258,9 @@ describe('ui/ext_messages', function()
{1:~ }|*9
{3:[No Name] }|
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { ' laststatus=3' } }, kind = '' },
+ { content = { { ' laststatus=3' } }, kind = 'list_cmd', history = false },
},
})
@@ -1910,8 +2279,9 @@ describe('ui/ext_messages', function()
{1:~ }|*10
{3:[No Name] }|
]],
+ cmdline = { { abort = false } },
messages = {
- { content = { { ' cmdheight=0' } }, kind = '' },
+ { content = { { ' cmdheight=0' } }, kind = 'list_cmd', history = false },
},
})
end)
@@ -2015,7 +2385,7 @@ describe('ui/msg_puts_printf', function()
)
cmd = cmd .. '"' .. nvim_prog .. '" -u NONE -i NONE -Es -V1'
- command([[call termopen(']] .. cmd .. [[')]])
+ command([[call jobstart(']] .. cmd .. [[',{'term':v:true})]])
screen:expect([[
^Exモードに入ります。ノー |
マルモードに戻るには "vis|