mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
Problem: Storing the configured 'cmdheight' value is scheduled and may happen after cmdline2_spec already entered block_mode. Excessive wait time for expected screen state due to delayed ruler after an error message. Solution: Only schedule storing the user configured 'cmdheight' if v:vim_did_enter is unset. Use regular message instead of error.
193 lines
8.2 KiB
Lua
193 lines
8.2 KiB
Lua
-- Tests for (protocol-driven) ui2, intended to replace the legacy message grid UI.
|
|
|
|
local n = require('test.functional.testnvim')()
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local clear, command, exec_lua, feed = n.clear, n.command, n.exec_lua, n.feed
|
|
|
|
describe('messages2', function()
|
|
local screen
|
|
before_each(function()
|
|
clear()
|
|
screen = Screen.new()
|
|
screen:add_extra_attr_ids({
|
|
[100] = { foreground = Screen.colors.Magenta1, bold = true },
|
|
})
|
|
exec_lua(function()
|
|
require('vim._extui').enable({})
|
|
end)
|
|
end)
|
|
|
|
it('multiline messages and pager', function()
|
|
command('echo "foo\nbar"')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*12
|
|
foo[+1] |
|
|
]])
|
|
command('set ruler showcmd noshowmode')
|
|
feed('g<lt>')
|
|
screen:expect([[
|
|
|
|
|
{1:~ }|*9
|
|
{3:─────────────────────────────────────────────────────}|
|
|
fo^o |
|
|
bar |
|
|
1,3 All|
|
|
]])
|
|
-- Multiple messages in same event loop iteration are appended and shown in full.
|
|
feed([[q:echo "foo" | echo "bar\nbaz\n"->repeat(&lines)<CR>]])
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*5
|
|
{3:─────────────────────────────────────────────────────}|
|
|
foo |
|
|
bar |
|
|
baz |
|
|
bar |
|
|
baz |
|
|
bar |
|
|
baz[+23] |
|
|
]])
|
|
-- Any key press resizes the cmdline and updates the spill indicator.
|
|
feed('j')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*12
|
|
foo[+29] 0,0-1 All|
|
|
]])
|
|
command('echo "foo"')
|
|
-- New message clears spill indicator.
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*12
|
|
foo 0,0-1 All|
|
|
]])
|
|
-- No error for ruler virt_text msg_row exceeding buffer length.
|
|
command([[map Q <cmd>echo "foo\nbar" <bar> ls<CR>]])
|
|
feed('Q')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*8
|
|
{3:─────────────────────────────────────────────────────}|
|
|
foo |
|
|
bar |
|
|
|
|
|
1 %a "[No Name]" line 1 |
|
|
]])
|
|
feed('<C-L>')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*12
|
|
0,0-1 All|
|
|
]])
|
|
-- edit_unputchar() does not clear already updated screen #34515.
|
|
feed('ix<Esc>dwi<C-r>')
|
|
screen:expect([[
|
|
{18:^"} |
|
|
{1:~ }|*12
|
|
^R 1,1 All|
|
|
]])
|
|
feed('-')
|
|
screen:expect([[
|
|
x^ |
|
|
{1:~ }|*12
|
|
1,2 All|
|
|
]])
|
|
end)
|
|
|
|
it('new buffer, window and options after closing a buffer', function()
|
|
command('set nomodifiable | echom "foo" | messages')
|
|
screen:expect([[
|
|
|
|
|
{1:~ }|*10
|
|
{3:─────────────────────────────────────────────────────}|
|
|
fo^o |
|
|
foo |
|
|
]])
|
|
command('bdelete | messages')
|
|
screen:expect_unchanged()
|
|
end)
|
|
|
|
it('screenclear and empty message clears messages', function()
|
|
command('echo "foo"')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*12
|
|
foo |
|
|
]])
|
|
command('mode')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*12
|
|
|
|
|
]])
|
|
command('echo "foo"')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*12
|
|
foo |
|
|
]])
|
|
command('echo ""')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*12
|
|
|
|
|
]])
|
|
command('set cmdheight=0')
|
|
command('echo "foo"')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*10
|
|
{1:~ }|
|
|
{1:~ }|
|
|
{1:~ }{4:foo}|
|
|
]])
|
|
command('mode')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*13
|
|
]])
|
|
-- But not with target='msg'
|
|
command('echo "foo"')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*10
|
|
{1:~ }|
|
|
{1:~ }|
|
|
{1:~ }{4:foo}|
|
|
]])
|
|
command('echo ""')
|
|
screen:expect_unchanged()
|
|
-- Or a screen resize
|
|
screen:try_resize(screen._width, screen._height - 1)
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*9
|
|
{1:~ }|
|
|
{1:~ }|
|
|
{1:~ }{4:foo}|
|
|
]])
|
|
-- Moved up when opening cmdline
|
|
feed(':')
|
|
screen:expect([[
|
|
|
|
|
{1:~ }|*10
|
|
{1:~ }{4:foo}|
|
|
{16::}^ |
|
|
]])
|
|
end)
|
|
|
|
it("deleting buffer restores 'buftype'", function()
|
|
feed(':%bdelete<CR>')
|
|
screen:expect([[
|
|
^ |
|
|
{1:~ }|*12
|
|
5 buffers deleted |
|
|
]])
|
|
-- Would trigger changed dialog if 'buftype' was not restored.
|
|
command('%bdelete')
|
|
screen:expect_unchanged()
|
|
end)
|
|
end)
|