-- Tests for (protocol-driven) ui2, intended to replace the legacy message grid UI.
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local describe, it, before_each, after_each, finally =
t.describe, t.it, t.before_each, t.after_each, t.finally
local api, clear, command, exec_lua, feed = n.api, n.clear, n.command, n.exec_lua, n.feed
local msg_timeout = 400
local function set_msg_target_zero_ch()
exec_lua(function()
vim.o.messagesopt = 'hit-enter,history:500,progress:c,timeout:' .. msg_timeout
require('vim._core.ui2').enable({ msg = { targets = 'msg' } })
vim.o.cmdheight = 0
end)
end
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._core.ui2').enable({})
end)
end)
after_each(function()
-- Since ui2 module lasts until Nvim exits, there may be unfinished timers.
-- Close unfinished timers to avoid 2s delay on exit with ASAN or TSAN.
exec_lua(function()
vim.uv.walk(function(handle)
if not handle:is_closing() then
handle:close()
end
end)
end)
end)
it('multiline messages and pager', function()
command('set ruler showcmd noshowmode | echo "foo\nbar"')
screen:expect([[
^ |
{1:~ }|*10
{3: }|
foo |
bar |
]])
feed('g')
screen:expect([[
^ |
{1:~ }|*10
{3: }|
foo |
bar g |
]])
feed
|