aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-11-14 13:10:32 +0100
committerGitHub <noreply@github.com>2024-11-14 13:10:32 +0100
commit7d771c3eeef5b4dca9ebc5ed6f7ca03f2b26b6bc (patch)
treefc5908c85c0cc6affc3bc325cd75f6efaeea95d8 /test/functional/ui
parent40dee8a2dcba996badaa6182eb34fde1694f92a3 (diff)
parente61228a214ebda9845db9462dad0a8c362d3963f (diff)
downloadrneovim-7d771c3eeef5b4dca9ebc5ed6f7ca03f2b26b6bc.tar.gz
rneovim-7d771c3eeef5b4dca9ebc5ed6f7ca03f2b26b6bc.tar.bz2
rneovim-7d771c3eeef5b4dca9ebc5ed6f7ca03f2b26b6bc.zip
Merge pull request #31168 from bfredl/noattach
fix(tests): needing two calls to setup a screen is cringe
Diffstat (limited to 'test/functional/ui')
-rw-r--r--test/functional/ui/bufhl_spec.lua1
-rw-r--r--test/functional/ui/cmdline_highlight_spec.lua1
-rw-r--r--test/functional/ui/cmdline_spec.lua22
-rw-r--r--test/functional/ui/cursor_spec.lua1
-rw-r--r--test/functional/ui/decorations_spec.lua7
-rw-r--r--test/functional/ui/diff_spec.lua10
-rw-r--r--test/functional/ui/embed_spec.lua17
-rw-r--r--test/functional/ui/float_spec.lua8
-rw-r--r--test/functional/ui/fold_spec.lua3
-rw-r--r--test/functional/ui/highlight_spec.lua39
-rw-r--r--test/functional/ui/hlstate_spec.lua7
-rw-r--r--test/functional/ui/inccommand_spec.lua13
-rw-r--r--test/functional/ui/inccommand_user_spec.lua2
-rw-r--r--test/functional/ui/input_spec.lua3
-rw-r--r--test/functional/ui/linematch_spec.lua4
-rw-r--r--test/functional/ui/messages_spec.lua17
-rw-r--r--test/functional/ui/mode_spec.lua3
-rw-r--r--test/functional/ui/mouse_spec.lua1
-rw-r--r--test/functional/ui/multibyte_spec.lua4
-rw-r--r--test/functional/ui/multigrid_spec.lua3
-rw-r--r--test/functional/ui/options_spec.lua10
-rw-r--r--test/functional/ui/output_spec.lua3
-rw-r--r--test/functional/ui/popupmenu_spec.lua10
-rw-r--r--test/functional/ui/quickfix_spec.lua1
-rw-r--r--test/functional/ui/screen.lua89
-rw-r--r--test/functional/ui/screen_basic_spec.lua10
-rw-r--r--test/functional/ui/scrollbind_spec.lua1
-rw-r--r--test/functional/ui/searchhl_spec.lua1
-rw-r--r--test/functional/ui/sign_spec.lua1
-rw-r--r--test/functional/ui/spell_spec.lua1
-rw-r--r--test/functional/ui/statuscolumn_spec.lua1
-rw-r--r--test/functional/ui/statusline_spec.lua13
-rw-r--r--test/functional/ui/syntax_conceal_spec.lua1
-rw-r--r--test/functional/ui/tabline_spec.lua4
-rw-r--r--test/functional/ui/title_spec.lua1
-rw-r--r--test/functional/ui/wildmode_spec.lua5
-rw-r--r--test/functional/ui/winbar_spec.lua3
37 files changed, 85 insertions, 236 deletions
diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua
index 5590db5bc4..b7cf8504ff 100644
--- a/test/functional/ui/bufhl_spec.lua
+++ b/test/functional/ui/bufhl_spec.lua
@@ -16,7 +16,6 @@ describe('Buffer highlighting', function()
clear()
command('syntax on')
screen = Screen.new(40, 8)
- screen:attach()
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue },
[2] = { foreground = Screen.colors.Fuchsia }, -- String
diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua
index 1c6f19245a..0ee994ba0a 100644
--- a/test/functional/ui/cmdline_highlight_spec.lua
+++ b/test/functional/ui/cmdline_highlight_spec.lua
@@ -24,7 +24,6 @@ end
before_each(function()
clear()
screen = Screen.new(40, 8)
- screen:attach()
source([[
highlight RBP1 guibg=Red
highlight RBP2 guibg=Yellow
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index 5c9ee61db9..0221c1e0b0 100644
--- a/test/functional/ui/cmdline_spec.lua
+++ b/test/functional/ui/cmdline_spec.lua
@@ -13,19 +13,12 @@ local eq = t.eq
local is_os = t.is_os
local api = n.api
--- TODO(bfredl): make Screen.new(cols, rows, {opts}) just work already
-local function new_screen(opt)
- local screen = Screen.new(25, 5)
- screen:attach(opt)
- return screen
-end
-
local function test_cmdline(linegrid)
local screen
before_each(function()
clear()
- screen = new_screen({ rgb = true, ext_cmdline = true, ext_linegrid = linegrid })
+ screen = Screen.new(25, 5, { rgb = true, ext_cmdline = true, ext_linegrid = linegrid })
end)
it('works', function()
@@ -849,7 +842,7 @@ describe('cmdline redraw', function()
local screen
before_each(function()
clear()
- screen = new_screen({ rgb = true })
+ screen = Screen.new(25, 5, { rgb = true })
end)
it('with timer', function()
@@ -1014,7 +1007,7 @@ describe('statusline is redrawn on entering cmdline', function()
before_each(function()
clear()
- screen = new_screen()
+ screen = Screen.new(25, 5)
command('set laststatus=2')
end)
@@ -1186,7 +1179,6 @@ end)
it('tabline is not redrawn in Ex mode #24122', function()
clear()
local screen = Screen.new(60, 5)
- screen:attach()
exec([[
set showtabline=2
@@ -1226,7 +1218,6 @@ describe('cmdline height', function()
it('does not crash resized screen #14263', function()
local screen = Screen.new(25, 10)
- screen:attach()
command('set cmdheight=9999')
screen:try_resize(25, 5)
assert_alive()
@@ -1247,7 +1238,6 @@ describe('cmdheight=0', function()
before_each(function()
clear()
screen = Screen.new(25, 5)
- screen:attach()
end)
it('with redrawdebug=invalid resize -1', function()
@@ -1514,7 +1504,7 @@ describe('cmdheight=0', function()
it('with silent! at startup', function()
clear { args = { '-c', 'set cmdheight=0', '-c', 'autocmd VimEnter * silent! call Foo()' } }
- screen:attach()
+ screen = Screen.new(25, 5)
-- doesn't crash while not displaying silent! error message
screen:expect {
grid = [[
@@ -1526,7 +1516,7 @@ describe('cmdheight=0', function()
it('with multigrid', function()
clear { args = { '--cmd', 'set cmdheight=0' } }
- screen:attach { ext_multigrid = true }
+ screen = Screen.new(25, 5, { ext_multigrid = true })
api.nvim_buf_set_lines(0, 0, -1, true, { 'p' })
screen:expect {
grid = [[
@@ -1689,7 +1679,7 @@ describe('cmdheight=0', function()
it('can be resized with external messages', function()
clear()
- screen = new_screen({ rgb = true, ext_messages = true })
+ screen = Screen.new(25, 5, { rgb = true, ext_messages = true })
command('set laststatus=2 mouse=a')
command('resize -1')
screen:expect([[
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index 619153724b..d7c0657820 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -12,7 +12,6 @@ describe('ui/cursor', function()
before_each(function()
clear()
screen = Screen.new(25, 5)
- screen:attach()
end)
it("'guicursor' is published as a UI event", function()
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index d96f614cd9..fbf16f3afe 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -20,7 +20,6 @@ describe('decorations providers', function()
before_each(function()
clear()
screen = Screen.new(40, 8)
- screen:attach()
screen:set_default_attr_ids {
[1] = {bold=true, foreground=Screen.colors.Blue};
[2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red};
@@ -766,7 +765,6 @@ describe('extmark decorations', function()
before_each( function()
clear()
screen = Screen.new(50, 15)
- screen:attach()
screen:set_default_attr_ids {
[1] = {bold=true, foreground=Screen.colors.Blue};
[2] = {foreground = Screen.colors.Brown};
@@ -2501,7 +2499,6 @@ describe('decorations: inline virtual text', function()
before_each( function()
clear()
screen = Screen.new(50, 3)
- screen:attach()
screen:set_default_attr_ids {
[1] = {bold=true, foreground=Screen.colors.Blue};
[2] = {foreground = Screen.colors.Brown};
@@ -4121,7 +4118,6 @@ describe('decorations: virtual lines', function()
before_each(function()
clear()
screen = Screen.new(50, 12)
- screen:attach()
screen:add_extra_attr_ids {
[100] = { foreground = Screen.colors.Blue, background = Screen.colors.Yellow },
}
@@ -5046,7 +5042,6 @@ describe('decorations: signs', function()
before_each(function()
clear()
screen = Screen.new(50, 10)
- screen:attach()
screen:add_extra_attr_ids {
[100] = { foreground = Screen.colors.Blue, background = Screen.colors.Yellow },
}
@@ -5662,7 +5657,6 @@ describe('decorations: virt_text', function()
before_each(function()
clear()
screen = Screen.new(50, 10)
- screen:attach()
end)
it('avoids regression in #17638', function()
@@ -5737,7 +5731,6 @@ describe('decorations: window scoped', function()
before_each(function()
clear()
screen = Screen.new(20, 10)
- screen:attach()
screen:add_extra_attr_ids {
[100] = { special = Screen.colors.Red, undercurl = true },
[101] = { url = 'https://example.com' },
diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua
index 8b965e8a97..95159011f1 100644
--- a/test/functional/ui/diff_spec.lua
+++ b/test/functional/ui/diff_spec.lua
@@ -53,7 +53,6 @@ describe('Diff mode screen', function()
feed('<c-w>w:diffthis<cr><c-w>w')
screen = Screen.new(40, 16)
- screen:attach()
end)
it('Add a line in beginning of file 2', function()
@@ -1172,7 +1171,6 @@ end)
it('win_update redraws lines properly', function()
local screen
screen = Screen.new(50, 10)
- screen:attach()
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue1 },
[2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
@@ -1250,7 +1248,6 @@ end)
-- oldtest: Test_diff_rnu()
it('diff updates line numbers below filler lines', function()
local screen = Screen.new(40, 14)
- screen:attach()
exec([[
call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
vnew
@@ -1310,7 +1307,6 @@ end)
-- oldtest: Test_diff_with_scroll_and_change()
it('Align the filler lines when changing text in diff mode', function()
local screen = Screen.new(40, 20)
- screen:attach()
exec([[
call setline(1, range(1, 15))
vnew
@@ -1376,7 +1372,6 @@ end)
it("diff mode doesn't restore invalid 'foldcolumn' value #21647", function()
local screen = Screen.new(60, 6)
- screen:attach()
eq('0', api.nvim_get_option_value('foldcolumn', {}))
command('diffsplit | bd')
screen:expect([[
@@ -1389,7 +1384,6 @@ end)
it("'relativenumber' doesn't draw beyond end of window in diff mode #29403", function()
local screen = Screen.new(60, 12)
- screen:attach()
command('set relativenumber')
feed('10aa<CR><Esc>gg')
command('vnew')
@@ -1433,7 +1427,6 @@ it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', fun
screen:add_extra_attr_ids {
[100] = { foreground = Screen.colors.Blue, bold = true, background = Screen.colors.Red },
}
- screen:attach()
exec([[
call setline(1, ['a', 'b', "c\n", 'd', 'e', 'f', 'g'])
vnew
@@ -1510,7 +1503,6 @@ end)
-- oldtest: Test_diff_breakindent_after_filler()
it("diff mode draws 'breakindent' correctly after filler lines", function()
local screen = Screen.new(45, 8)
- screen:attach()
exec([[
set laststatus=0 diffopt+=followwrap breakindent breakindentopt=min:0
call setline(1, ['a', ' ' .. repeat('c', 50)])
@@ -1562,7 +1554,6 @@ it('diff mode overlapped diff blocks will be merged', function()
]])
local screen = Screen.new(35, 20)
- screen:attach()
command('set winwidth=10 diffopt=filler,internal')
command('args Xdifile1 Xdifile2 | vert all | windo diffthis')
@@ -2058,7 +2049,6 @@ end)
-- oldtest: Test_diff_topline_noscroll()
it('diff mode does not scroll with line("w0")', function()
local screen = Screen.new(45, 20)
- screen:attach()
exec([[
set scrolloff=5
call setline(1, range(1,60))
diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua
index f525b23f7d..977141ae3e 100644
--- a/test/functional/ui/embed_spec.lua
+++ b/test/functional/ui/embed_spec.lua
@@ -25,8 +25,7 @@ local function test_embed(ext_linegrid)
clear { args_rm = { '--headless' }, args = { ... } }
-- attach immediately after startup, for early UI
- screen = Screen.new(60, 8)
- screen:attach { ext_linegrid = ext_linegrid }
+ screen = Screen.new(60, 8, { ext_linegrid = ext_linegrid })
screen:add_extra_attr_ids {
[100] = { foreground = Screen.colors.NvimDarkCyan },
[101] = { foreground = Screen.colors.NvimDarkRed },
@@ -110,9 +109,10 @@ describe('--embed UI', function()
clear { args_rm = { '--headless' }, io_extra = pipe.read, env = { NVIM_LOG_FILE = testlog } }
-- attach immediately after startup, for early UI
- local screen = Screen.new(40, 8)
+ -- rpc_async: Avoid hanging. #24888
+ local screen = Screen.new(40, 8, { stdin_fd = 3 }, false)
screen.rpc_async = true -- Avoid hanging. #24888
- screen:attach { stdin_fd = 3 }
+ screen:attach()
writer:write 'hello nvim\nfrom external input\n'
writer:shutdown(function()
@@ -164,9 +164,9 @@ describe('--embed UI', function()
clear { args_rm = { '--headless' }, args = { '-q', '-' }, io_extra = pipe.read }
-- attach immediately after startup, for early UI
- local screen = Screen.new(60, 8)
+ local screen = Screen.new(60, 8, { stdin_fd = 3 }, false)
screen.rpc_async = true -- Avoid hanging. #24888
- screen:attach { stdin_fd = 3 }
+ screen:attach()
writer:write [[Xbadfile.c:4:12: error: expected ';' before '}' token]]
writer:shutdown(function()
@@ -212,7 +212,6 @@ describe('--embed UI', function()
-- attach immediately after startup, for early UI
screen = Screen.new(40, 8)
screen._handle_default_colors_set = handle_default_colors_set
- screen:attach()
end
startup()
@@ -239,7 +238,6 @@ describe('--embed UI', function()
clear { args_rm = { '--headless' } }
local screen = Screen.new(40, 8)
- screen:attach()
screen:expect {
condition = function()
@@ -326,8 +324,7 @@ describe('--embed --listen UI', function()
ok(var_ok)
eq({}, var)
- 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:expect {
grid = [[
^ |
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index b76474fd58..57ef9bcff6 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -640,8 +640,7 @@ describe('float window', function()
end)
it('tp_curwin updated if external window is moved into split', function()
- local screen = Screen.new(20, 7)
- screen:attach { ext_multigrid = true }
+ local _ = Screen.new(20, 7, { ext_multigrid = true })
command('tabnew')
local external_win = api.nvim_open_win(0, true, {external = true, width = 5, height = 5})
@@ -658,8 +657,6 @@ describe('float window', function()
command('tabnext')
eq(2, fn.tabpagenr())
neq(external_win, api.nvim_get_current_win())
-
- screen:detach()
end)
it('no crash with relative="win" after %bdelete #30569', function()
@@ -1018,8 +1015,7 @@ describe('float window', function()
local function with_ext_multigrid(multigrid)
local screen, attrs
before_each(function()
- screen = Screen.new(40,7)
- screen:attach {ext_multigrid=multigrid}
+ screen = Screen.new(40,7, {ext_multigrid=multigrid})
attrs = {
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {background = Screen.colors.LightMagenta},
diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua
index 8f6e8aef7e..aea629df07 100644
--- a/test/functional/ui/fold_spec.lua
+++ b/test/functional/ui/fold_spec.lua
@@ -28,8 +28,7 @@ describe('folded lines', function()
local function with_ext_multigrid(multigrid)
local screen
before_each(function()
- screen = Screen.new(45, 8)
- screen:attach({ rgb = true, ext_multigrid = multigrid })
+ screen = Screen.new(45, 8, { rgb = true, ext_multigrid = multigrid })
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue1 },
[2] = { reverse = true },
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index c989418409..0f4696f3d3 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -32,7 +32,6 @@ describe('highlight: `:syntax manual`', function()
before_each(function()
clear()
screen = Screen.new(20, 5)
- screen:attach()
-- syntax highlight for vimscript's "echo"
end)
@@ -93,7 +92,6 @@ describe('highlight defaults', function()
[100] = { foreground = Screen.colors.Red, background = Screen.colors.WebGreen },
[101] = { italic = true },
}
- screen:attach()
end)
it('window status bar', function()
@@ -303,7 +301,6 @@ describe('highlight', function()
it('Visual', function()
local screen = Screen.new(45, 5)
- screen:attach()
insert([[
line1 foo bar
abcdefghijklmnopqrs
@@ -428,7 +425,6 @@ describe('highlight', function()
it('cterm=standout gui=standout', function()
local screen = Screen.new(20, 5)
- screen:attach()
screen:add_extra_attr_ids {
[100] = {
foreground = Screen.colors.Blue1,
@@ -454,7 +450,6 @@ describe('highlight', function()
it('strikethrough', function()
local screen = Screen.new(25, 6)
- screen:attach()
feed_command('syntax on')
feed_command('syn keyword TmpKeyword foo')
feed_command('hi! Awesome cterm=strikethrough gui=strikethrough')
@@ -490,7 +485,6 @@ describe('highlight', function()
background = Screen.colors.Yellow,
},
}
- screen:attach()
feed_command('syntax on')
feed_command('hi! Underlined cterm=underline gui=underline')
feed_command('syn keyword Underlined foobar')
@@ -532,7 +526,6 @@ describe('highlight', function()
it('guisp (special/undercurl)', function()
local screen = Screen.new(25, 10)
- screen:attach()
feed_command('syntax on')
feed_command('syn keyword TmpKeyword neovim')
feed_command('syn keyword TmpKeyword1 special')
@@ -585,7 +578,6 @@ describe('highlight', function()
it("'diff', syntax and extmark #23722", function()
local screen = Screen.new(25, 10)
- screen:attach()
exec([[
new
call setline(1, ['', '01234 6789'])
@@ -631,7 +623,6 @@ describe("'listchars' highlight", function()
before_each(function()
clear()
screen = Screen.new(20, 5)
- screen:attach()
end)
it("'cursorline' and 'cursorcolumn'", function()
@@ -873,7 +864,6 @@ describe('CursorLine and CursorLineNr highlights', function()
[100] = { background = Screen.colors.LightRed },
[101] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Grey90 },
}
- screen:attach()
command('filetype on')
command('syntax on')
@@ -906,7 +896,6 @@ describe('CursorLine and CursorLineNr highlights', function()
[102] = { foreground = Screen.colors.Grey0, background = Screen.colors.Grey100 },
[103] = { foreground = Screen.colors.Yellow1, background = Screen.colors.Grey100 },
}
- screen:attach()
feed_command('set wrap cursorline')
feed_command('set showbreak=>>>')
@@ -957,7 +946,6 @@ describe('CursorLine and CursorLineNr highlights', function()
[102] = { foreground = Screen.colors.Black, background = Screen.colors.Grey100 },
[103] = { foreground = Screen.colors.WebGreen, background = Screen.colors.Red },
}
- screen:attach()
command('set wrap cursorline cursorlineopt=screenline')
command('set showbreak=>>>')
@@ -1081,7 +1069,6 @@ describe('CursorLine and CursorLineNr highlights', function()
-- oldtest: Test_cursorline_screenline_resize()
it("'cursorlineopt' screenline is updated on window resize", function()
local screen = Screen.new(75, 8)
- screen:attach()
exec([[
50vnew
call setline(1, repeat('xyz ', 30))
@@ -1123,7 +1110,6 @@ describe('CursorLine and CursorLineNr highlights', function()
[100] = { background = Screen.colors.LightRed },
[101] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Grey90 },
}
- screen:attach()
command('set cursorline relativenumber')
command('call setline(1, ["","1","2","3",""])')
feed('Gy3k')
@@ -1151,7 +1137,6 @@ describe('CursorLine and CursorLineNr highlights', function()
[100] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Grey90 },
[101] = { background = Screen.colors.LightRed },
}
- screen:attach()
command('set cursorline')
command('call setline(1, repeat(["abc"], 50))')
feed('V<C-f>zbkkjk')
@@ -1166,7 +1151,6 @@ describe('CursorLine and CursorLineNr highlights', function()
-- oldtest: Test_cursorline_callback()
it('is updated if cursor is moved up from timer vim-patch:8.2.4591', function()
local screen = Screen.new(50, 8)
- screen:attach()
exec([[
call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'])
set cursorline
@@ -1207,7 +1191,6 @@ describe('CursorLine and CursorLineNr highlights', function()
[100] = { background = Screen.colors.Plum1, underline = true },
[101] = { background = Screen.colors.Red1, bold = true, underline = true },
}
- screen:attach()
command('hi CursorLine ctermbg=red ctermfg=white guibg=red guifg=white')
command('set cursorline')
@@ -1267,7 +1250,6 @@ describe('CursorLine and CursorLineNr highlights', function()
screen:add_extra_attr_ids {
[100] = { foreground = Screen.colors.Black, bold = true, background = Screen.colors.Grey100 },
}
- screen:attach()
command('hi CursorLine guibg=red guifg=white')
command('hi CursorLineNr guibg=white guifg=black gui=bold')
@@ -1308,7 +1290,6 @@ describe('CursorColumn highlight', function()
screen:add_extra_attr_ids {
[100] = { background = Screen.colors.Blue1 },
}
- screen:attach()
end)
it('is updated when pressing "i" on a TAB character', function()
@@ -1435,7 +1416,6 @@ describe('ColorColumn highlight', function()
[101] = { background = Screen.colors.LightRed },
[102] = { foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.LightRed },
}
- screen:attach()
end)
-- oldtest: Test_colorcolumn()
@@ -1538,7 +1518,6 @@ describe('MsgSeparator highlight and msgsep fillchar', function()
[12] = { background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x297d4e') },
[13] = { background = tonumber('0xff4cff'), bold = true, foreground = tonumber('0xb200ff') },
})
- screen:attach()
end)
it('works', function()
@@ -1653,7 +1632,6 @@ describe("'winhighlight' highlight", function()
before_each(function()
clear()
screen = Screen.new(20, 8)
- screen:attach()
screen:set_default_attr_ids {
[0] = { bold = true, foreground = Screen.colors.Blue },
[1] = { background = Screen.colors.DarkBlue },
@@ -2317,7 +2295,6 @@ describe('highlight namespaces', function()
before_each(function()
clear()
screen = Screen.new(25, 10)
- screen:attach()
screen:set_default_attr_ids {
[1] = { foreground = Screen.colors.Blue, bold = true },
[2] = { background = Screen.colors.DarkGrey },
@@ -2467,10 +2444,8 @@ describe('highlight namespaces', function()
end)
describe('synIDattr()', function()
- local screen
before_each(function()
clear()
- screen = Screen.new(50, 7)
command('highlight Normal ctermfg=252 guifg=#ff0000 guibg=Black')
-- Salmon #fa8072 Maroon #800000
command(
@@ -2495,7 +2470,7 @@ describe('synIDattr()', function()
end)
it('returns gui-color if RGB-capable UI is attached', function()
- screen:attach({ rgb = true })
+ local _ = Screen.new(50, 7, { rgb = true })
eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg")'))
eq('Black', eval('synIDattr(hlID("Normal"), "bg")'))
eq('Salmon', eval('synIDattr(hlID("Keyword"), "fg")'))
@@ -2503,15 +2478,15 @@ describe('synIDattr()', function()
end)
it('returns #RRGGBB value for fg#/bg#/sp#', function()
- screen:attach({ rgb = true })
+ local _ = Screen.new(50, 7, { rgb = true })
eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg#")'))
eq('#000000', eval('synIDattr(hlID("Normal"), "bg#")'))
eq('#fa8072', eval('synIDattr(hlID("Keyword"), "fg#")'))
eq('#800000', eval('synIDattr(hlID("Keyword"), "sp#")'))
end)
- it('returns color number if non-GUI', function()
- screen:attach({ rgb = false })
+ it('returns color number if non-RGB GUI', function()
+ local _ = Screen.new(50, 7, { rgb = false })
eq('252', eval('synIDattr(hlID("Normal"), "fg")'))
eq('79', eval('synIDattr(hlID("Keyword"), "fg")'))
end)
@@ -2536,10 +2511,8 @@ describe('synIDattr()', function()
end)
describe('fg/bg special colors', function()
- local screen
before_each(function()
clear()
- screen = Screen.new(50, 7)
command('highlight Normal ctermfg=145 ctermbg=16 guifg=#ff0000 guibg=Black')
command('highlight Visual ctermfg=bg ctermbg=fg guifg=bg guibg=fg guisp=bg')
end)
@@ -2558,7 +2531,7 @@ describe('fg/bg special colors', function()
end)
it('resolve to "Normal" values in RGB-capable UI', function()
- screen:attach({ rgb = true })
+ local _ = Screen.new(50, 7, { rgb = true })
eq('bg', eval('synIDattr(hlID("Visual"), "fg")'))
eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "fg#")'))
eq('fg', eval('synIDattr(hlID("Visual"), "bg")'))
@@ -2568,7 +2541,7 @@ describe('fg/bg special colors', function()
end)
it('resolve after the "Normal" group is modified', function()
- screen:attach({ rgb = true })
+ local _ = Screen.new(50, 7, { rgb = true })
local new_guibg = '#282c34'
local new_guifg = '#abb2bf'
command('highlight Normal guifg=' .. new_guifg .. ' guibg=' .. new_guibg)
diff --git a/test/functional/ui/hlstate_spec.lua b/test/functional/ui/hlstate_spec.lua
index 9873ab3103..f8f5ee9488 100644
--- a/test/functional/ui/hlstate_spec.lua
+++ b/test/functional/ui/hlstate_spec.lua
@@ -17,12 +17,7 @@ describe('ext_hlstate detailed highlights', function()
clear()
command('syntax on')
command('hi VertSplit gui=reverse')
- screen = Screen.new(40, 8)
- screen:attach({ ext_hlstate = true })
- end)
-
- after_each(function()
- screen:detach()
+ screen = Screen.new(40, 8, { ext_hlstate = true })
end)
it('work with combined UI and syntax highlights', function()
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index c11e009fef..37dc0f5195 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -66,7 +66,6 @@ local function common_setup(screen, inccommand, text)
command('syntax on')
command('set nohlsearch')
command('hi Substitute guifg=red guibg=yellow')
- screen:attach()
screen:add_extra_attr_ids {
[100] = { underline = true },
@@ -556,10 +555,9 @@ describe(":substitute, 'inccommand' preserves undo", function()
end)
it('with undolevels=1', function()
- local screen = Screen.new(20, 10)
-
for _, case in pairs(cases) do
clear()
+ local screen = Screen.new(20, 10)
common_setup(screen, case, default_text)
screen:expect([[
Inc substitution on |
@@ -617,10 +615,9 @@ describe(":substitute, 'inccommand' preserves undo", function()
end)
it('with undolevels=2', function()
- local screen = Screen.new(20, 10)
-
for _, case in pairs(cases) do
clear()
+ local screen = Screen.new(20, 10)
common_setup(screen, case, default_text)
command('set undolevels=2')
@@ -697,10 +694,9 @@ describe(":substitute, 'inccommand' preserves undo", function()
end)
it('with undolevels=-1', function()
- local screen = Screen.new(20, 10)
-
for _, case in pairs(cases) do
clear()
+ local screen = Screen.new(20, 10)
common_setup(screen, case, default_text)
command('set undolevels=-1')
@@ -728,6 +724,7 @@ describe(":substitute, 'inccommand' preserves undo", function()
-- repeat with an interrupted substitution
clear()
+ screen = Screen.new(20, 10)
common_setup(screen, case, default_text)
command('set undolevels=-1')
@@ -2510,7 +2507,7 @@ describe(':substitute', function()
end)
it("doesn't prompt to swap cmd range", function()
- screen = Screen.new(50, 8) -- wide to avoid hit-enter prompt
+ screen:try_resize(50, 8) -- wide to avoid hit-enter prompt
common_setup(screen, 'split', default_text)
feed(':2,1s/tw/MO/g')
diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua
index e8b546d33a..2d26d2c5e0 100644
--- a/test/functional/ui/inccommand_user_spec.lua
+++ b/test/functional/ui/inccommand_user_spec.lua
@@ -239,7 +239,6 @@ describe("'inccommand' for user commands", function()
before_each(function()
clear()
screen = Screen.new(40, 17)
- screen:attach()
exec_lua(setup_replace_cmd)
command('set cmdwinheight=5')
insert [[
@@ -549,7 +548,6 @@ describe("'inccommand' with multiple buffers", function()
before_each(function()
clear()
screen = Screen.new(40, 17)
- screen:attach()
exec_lua(setup_replace_cmd)
command('set cmdwinheight=10')
insert [[
diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua
index f377939458..90e0b3e380 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -282,7 +282,6 @@ end)
it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2.0839', function()
local screen = Screen.new(60, 8)
- screen:attach()
command([[nnoremap <C-6> <Cmd>echo 'hit ctrl-6'<CR>]])
feed_command('ls')
screen:expect([[
@@ -328,7 +327,6 @@ describe('input non-printable chars', function()
it("doesn't crash when echoing them back", function()
write_file('Xtest-overwrite', [[foobar]])
local screen = Screen.new(60, 8)
- screen:attach()
command('set shortmess-=F')
feed_command('e Xtest-overwrite')
@@ -428,7 +426,6 @@ describe('display is updated', function()
local screen
before_each(function()
screen = Screen.new(60, 8)
- screen:attach()
end)
it('in Insert mode after <Nop> mapping #17911', function()
diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua
index 03eed5a49c..b564c01eaa 100644
--- a/test/functional/ui/linematch_spec.lua
+++ b/test/functional/ui/linematch_spec.lua
@@ -38,7 +38,6 @@ describe('Diff mode screen with 3 diffs open', function()
feed(':windo diffthis<cr>')
screen = Screen.new(100, 16)
- screen:attach()
feed('<c-w>=')
feed(':windo set nu!<cr>')
end)
@@ -217,7 +216,6 @@ describe('Diff mode screen with 2 diffs open', function()
feed(':windo diffthis<cr>')
screen = Screen.new(100, 20)
- screen:attach()
feed('<c-w>=')
feed(':windo set nu!<cr>')
end)
@@ -1093,7 +1091,6 @@ describe('regressions', function()
clear()
feed(':set diffopt+=linematch:30<cr>')
screen = Screen.new(100, 20)
- screen:attach()
-- line must be greater than MATCH_CHAR_MAX_LEN
n.api.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 1000) .. 'hello' })
n.exec 'vnew'
@@ -1105,7 +1102,6 @@ describe('regressions', function()
clear()
feed(':set diffopt+=linematch:10<cr>')
screen = Screen.new(100, 20)
- screen:attach()
local lines = {}
for i = 0, 29 do
lines[#lines + 1] = tostring(i)
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 804ba83698..25f3465d46 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 },
}
@@ -1120,8 +1119,7 @@ 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 },
@@ -1669,8 +1667,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()
@@ -1895,8 +1892,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 = [[
@@ -1971,7 +1967,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
@@ -2012,7 +2007,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 },
@@ -2808,8 +2802,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")]])
diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua
index f623cfda06..8c6a284cd6 100644
--- a/test/functional/ui/mode_spec.lua
+++ b/test/functional/ui/mode_spec.lua
@@ -11,8 +11,7 @@ describe('ui mode_change event', function()
before_each(function()
clear()
- screen = Screen.new(25, 4)
- screen:attach({ rgb = true })
+ screen = Screen.new(25, 4, { rgb = true })
end)
it('works in normal mode', function()
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua
index 3f071ffd6a..3ee4d429c7 100644
--- a/test/functional/ui/mouse_spec.lua
+++ b/test/functional/ui/mouse_spec.lua
@@ -21,7 +21,6 @@ describe('ui/mouse/input', function()
command('set listchars=eol:$')
command('setl listchars=nbsp:x')
screen = Screen.new(25, 5)
- screen:attach()
screen:add_extra_attr_ids {
[100] = {
bold = true,
diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua
index 3728ec8dbc..001d3cb430 100644
--- a/test/functional/ui/multibyte_spec.lua
+++ b/test/functional/ui/multibyte_spec.lua
@@ -16,8 +16,7 @@ describe('multibyte rendering', function()
local screen
before_each(function()
clear()
- screen = Screen.new(60, 6)
- screen:attach({ rgb = true })
+ screen = Screen.new(60, 6, { rgb = true })
end)
it('works with composed char at start of line', function()
@@ -384,7 +383,6 @@ describe('multibyte rendering: statusline', function()
before_each(function()
clear()
screen = Screen.new(40, 4)
- screen:attach()
command('set laststatus=2')
end)
diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua
index e009ed0a29..3afda0c4af 100644
--- a/test/functional/ui/multigrid_spec.lua
+++ b/test/functional/ui/multigrid_spec.lua
@@ -16,8 +16,7 @@ describe('ext_multigrid', function()
before_each(function()
clear{args_rm={'--headless'}, args={'--cmd', 'set laststatus=2'}}
- screen = Screen.new(53,14)
- screen:attach({ext_multigrid=true})
+ screen = Screen.new(53,14, {ext_multigrid=true})
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue1},
[2] = {foreground = Screen.colors.Magenta},
diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua
index b40ff29dec..211fc1dc77 100644
--- a/test/functional/ui/options_spec.lua
+++ b/test/functional/ui/options_spec.lua
@@ -44,8 +44,7 @@ describe('UI receives option updates', function()
clear_opts.args_rm = clear_opts.args_rm or {}
table.insert(clear_opts.args_rm or {}, '--cmd')
clear(clear_opts)
- screen = Screen.new(20, 5)
- screen:attach(screen_opts)
+ screen = Screen.new(20, 5, screen_opts)
-- NB: UI test suite can be run in both "linegrid" and legacy grid mode.
-- In both cases check that the received value is the one requested.
defaults.ext_linegrid = screen._options.ext_linegrid or false
@@ -70,7 +69,6 @@ describe('UI receives option updates', function()
function screen:_handle_mouse_off()
table.insert(evs, 'mouse_off')
end
- screen:attach()
screen:expect(function()
eq({ 'mouse_on' }, evs)
end)
@@ -215,24 +213,22 @@ describe('UI receives option updates', function()
end)
describe('UI can set terminal option', function()
- local screen
before_each(function()
-- by default we implicitly "--cmd 'set bg=light'" which ruins everything
clear { args_rm = { '--cmd' } }
- screen = Screen.new(20, 5)
end)
it('term_name', function()
eq('nvim', eval '&term')
- screen:attach { term_name = 'xterm' }
+ local _ = Screen.new(20, 5, { term_name = 'xterm' })
eq('xterm', eval '&term')
end)
it('term_colors', function()
eq('256', eval '&t_Co')
- screen:attach { term_colors = 8 }
+ local _ = Screen.new(20, 5, { term_colors = 8 })
eq('8', eval '&t_Co')
end)
end)
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua
index 220af06f53..b5a09d814c 100644
--- a/test/functional/ui/output_spec.lua
+++ b/test/functional/ui/output_spec.lua
@@ -109,7 +109,6 @@ describe('shell command :!', function()
it('handles control codes', function()
skip(is_os('win'), 'missing printf')
local screen = Screen.new(50, 4)
- screen:attach()
-- Print TAB chars. #2958
feed([[:!printf '1\t2\t3'<CR>]])
screen:expect {
@@ -167,7 +166,6 @@ describe('shell command :!', function()
write_file('bang_filter_spec/f2', 'f2')
write_file('bang_filter_spec/f3', 'f3')
screen = Screen.new(53, 10)
- screen:attach()
end)
after_each(function()
@@ -241,7 +239,6 @@ describe('shell command :!', function()
it('powershell supports literal strings', function()
set_shell_powershell()
local screen = Screen.new(45, 4)
- screen:attach()
feed_command([[!'Write-Output $a']])
screen:expect([[
:!'Write-Output $a' |
diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua
index 2f7ff80f02..8fe8975b4a 100644
--- a/test/functional/ui/popupmenu_spec.lua
+++ b/test/functional/ui/popupmenu_spec.lua
@@ -19,8 +19,7 @@ describe('ui/ext_popupmenu', function()
local screen
before_each(function()
clear()
- screen = Screen.new(60, 8)
- screen:attach({ rgb = true, ext_popupmenu = true })
+ screen = Screen.new(60, 8, { rgb = true, ext_popupmenu = true })
source([[
function! TestComplete() abort
call complete(1, [{'word':'foo', 'abbr':'fo', 'menu':'the foo', 'info':'foo-y', 'kind':'x'}, 'bar', 'spam'])
@@ -957,7 +956,6 @@ describe("builtin popupmenu 'pumblend'", function()
[44] = { foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f') },
[45] = { background = Screen.colors.WebGray, blend = 0 },
})
- screen:attach()
command('syntax on')
command('set mouse=a')
command('set pumblend=10')
@@ -1107,7 +1105,7 @@ describe("builtin popupmenu 'pumblend'", function()
end)
it('256-color (non-RGB)', function()
- local screen = Screen.new(60, 8)
+ local screen = Screen.new(60, 8, { rgb = false })
screen:set_default_attr_ids({
[1] = { foreground = Screen.colors.Grey0, background = tonumber('0x000007') },
[2] = { foreground = tonumber('0x000055'), background = tonumber('0x000007') },
@@ -1120,7 +1118,6 @@ describe("builtin popupmenu 'pumblend'", function()
[9] = { bold = true },
[10] = { foreground = tonumber('0x000002') },
})
- screen:attach({ rgb = false })
command('set pumblend=10')
insert([[
Lorem ipsum dolor sit amet, consectetur
@@ -1149,7 +1146,7 @@ describe('builtin popupmenu', function()
local function with_ext_multigrid(multigrid)
local screen
before_each(function()
- screen = Screen.new(32, 20)
+ screen = Screen.new(32, 20, { ext_multigrid = multigrid })
screen:set_default_attr_ids({
-- popup selected item / scrollbar track
s = { background = Screen.colors.Grey },
@@ -1194,7 +1191,6 @@ describe('builtin popupmenu', function()
underline = true,
},
})
- screen:attach({ ext_multigrid = multigrid })
end)
it('with preview-window above', function()
diff --git a/test/functional/ui/quickfix_spec.lua b/test/functional/ui/quickfix_spec.lua
index 73923a153a..3750ce3d3f 100644
--- a/test/functional/ui/quickfix_spec.lua
+++ b/test/functional/ui/quickfix_spec.lua
@@ -11,7 +11,6 @@ describe('quickfix selection highlight', function()
clear()
screen = Screen.new(25, 10)
- screen:attach()
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue },
[2] = { reverse = true },
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 358e54dc55..8e15e6c35f 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -6,23 +6,15 @@
--
-- Example usage:
--
+-- -- Attach a screen to the current Nvim instance.
-- local screen = Screen.new(25, 10)
--- -- Attach the screen to the current Nvim instance.
--- screen:attach()
-- -- Enter insert-mode and type some text.
-- feed('ihello screen')
-- -- Assert the expected screen state.
-- screen:expect([[
--- hello screen |
--- ~ |
--- ~ |
--- ~ |
--- ~ |
--- ~ |
--- ~ |
--- ~ |
--- ~ |
--- -- INSERT -- |
+-- hello screen^ |
+-- {1:~ }|*8
+-- {5:-- INSERT --} |
-- ]]) -- <- Last line is stripped
--
-- Since screen updates are received asynchronously, expect() actually specifies
@@ -36,36 +28,19 @@
-- * If the timeout expires, the last match error will be reported and the
-- test will fail.
--
--- Continuing the above example, say we want to assert that "-- INSERT --" is
--- highlighted with the bold attribute. The expect() call should look like this:
---
--- NonText = Screen.colors.Blue
--- screen:expect([[
--- hello screen |
--- ~ |
--- ~ |
--- ~ |
--- ~ |
--- ~ |
--- ~ |
--- ~ |
--- ~ |
--- {b:-- INSERT --} |
--- ]], {b = {bold = true}}, {{bold = true, foreground = NonText}})
---
--- In this case "b" is a string associated with the set composed of one
--- attribute: bold. Note that since the {b:} markup is not a real part of the
+-- The 30 most common highlight groups are predefined, see init_colors() below.
+-- In this case "5" is a predefined highlight associated with the set composed of one
+-- attribute: bold. Note that since the {5:} markup is not a real part of the
-- screen, the delimiter "|" moved to the right. Also, the highlighting of the
--- NonText markers "~" is ignored in this test.
+-- NonText markers "~" is visible.
--
--- Tests will often share a group of attribute sets to expect(). Those can be
+-- Tests will often share a group of extra attribute sets to expect(). Those can be
-- defined at the beginning of a test:
--
--- NonText = Screen.colors.Blue
--- screen:set_default_attr_ids( {
--- [1] = {reverse = true, bold = true},
--- [2] = {reverse = true}
--- })
+-- screen:add_extra_attr_ids {
+-- [100] = { background = Screen.colors.Plum1, underline = true },
+-- [101] = { background = Screen.colors.Red1, bold = true, underline = true },
+-- }
--
-- To help write screen tests, see Screen:snapshot_util().
-- To debug screen tests, see Screen:redraw_debug().
@@ -180,14 +155,30 @@ local function _init_colors()
}
end
+--- @class test.functional.ui.screen.Opts
+--- @field ext_linegrid? boolean
+--- @field ext_multigrid? boolean
+--- @field ext_newgrid? boolean
+--- @field ext_popupmenu? boolean
+--- @field ext_wildmenu? boolean
+--- @field rgb? boolean
+--- @field _debug_float? boolean
+
--- @param width? integer
--- @param height? integer
+--- @param options? test.functional.ui.screen.Opts
+--- @param session? test.Session|false
--- @return test.functional.ui.screen
-function Screen.new(width, height)
+function Screen.new(width, height, options, session)
if not Screen.colors then
_init_colors()
end
+ options = options or {}
+ if options.ext_linegrid == nil then
+ options.ext_linegrid = true
+ end
+
local self = setmetatable({
timeout = default_screen_timeout,
title = '',
@@ -227,6 +218,7 @@ function Screen.new(width, height)
_new_attrs = false,
_width = width or 53,
_height = height or 14,
+ _options = options,
_grids = {},
_grid_win_extmarks = {},
_cursor = {
@@ -250,6 +242,11 @@ function Screen.new(width, height)
self.uimeths = create_callindex(ui)
+ -- session is often nil, which implies the default session
+ if session ~= false then
+ self:attach(session)
+ end
+
return self
end
@@ -277,20 +274,10 @@ function Screen:set_rgb_cterm(val)
self._rgb_cterm = val
end
---- @class test.functional.ui.screen.Opts
---- @field ext_linegrid? boolean
---- @field ext_multigrid? boolean
---- @field ext_newgrid? boolean
---- @field ext_popupmenu? boolean
---- @field ext_wildmenu? boolean
---- @field rgb? boolean
---- @field _debug_float? boolean
-
---- @param options? test.functional.ui.screen.Opts
--- @param session? test.Session
-function Screen:attach(options, session)
+function Screen:attach(session)
session = session or get_session()
- options = options or {}
+ local options = self._options
if options.ext_linegrid == nil then
options.ext_linegrid = true
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index 85a653df36..f39e9ecc33 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -29,7 +29,6 @@ describe('screen', function()
local screen_nvim = spawn(nvim_argv)
set_session(screen_nvim)
screen = Screen.new()
- screen:attach()
end)
it('default initial screen', function()
@@ -47,8 +46,7 @@ local function screen_tests(linegrid)
before_each(function()
clear()
- screen = Screen.new()
- screen:attach({ rgb = true, ext_linegrid = linegrid })
+ screen = Screen.new(53, 14, { rgb = true, ext_linegrid = linegrid })
screen:set_default_attr_ids({
[0] = { bold = true, foreground = 255 },
[1] = { bold = true, reverse = true },
@@ -717,8 +715,7 @@ describe('Screen default colors', function()
}
local screen_nvim = spawn(nvim_argv)
set_session(screen_nvim)
- screen = Screen.new()
- screen:attach(termcolors and { rgb = true, ext_termcolors = true } or { rgb = true })
+ screen = Screen.new(53, 14, { rgb = true, ext_termcolors = termcolors or nil })
end
it('are dark per default', function()
@@ -777,7 +774,6 @@ end)
it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function()
clear()
local screen = Screen.new(100, 100)
- screen:attach()
eq(100, api.nvim_get_option_value('lines', {}))
eq(99, api.nvim_get_option_value('window', {}))
eq(99, api.nvim_win_get_height(0))
@@ -810,7 +806,6 @@ end)
it("showcmd doesn't cause empty grid_line with redrawdebug=compositor #22593", function()
clear()
local screen = Screen.new(30, 2)
- screen:attach()
command('set showcmd redrawdebug=compositor')
feed('d')
screen:expect {
@@ -824,7 +819,6 @@ end)
it("scrolling in narrow window doesn't draw over separator #29033", function()
clear()
local screen = Screen.new(60, 8)
- screen:attach()
feed('100Oa<Esc>gg')
exec([[
set number nowrap
diff --git a/test/functional/ui/scrollbind_spec.lua b/test/functional/ui/scrollbind_spec.lua
index 9e70b25efa..84316762e4 100644
--- a/test/functional/ui/scrollbind_spec.lua
+++ b/test/functional/ui/scrollbind_spec.lua
@@ -10,7 +10,6 @@ describe('Scrollbind', function()
before_each(function()
screen = Screen.new(40, 12)
- screen:attach()
end)
it('works with one buffer with virtual lines', function()
diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua
index eab265cbb1..86490b4527 100644
--- a/test/functional/ui/searchhl_spec.lua
+++ b/test/functional/ui/searchhl_spec.lua
@@ -16,7 +16,6 @@ describe('search highlighting', function()
before_each(function()
clear()
screen = Screen.new(40, 7)
- screen:attach()
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue },
[2] = { background = Screen.colors.Yellow }, -- Search
diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua
index da61b6d30f..7874c04c39 100644
--- a/test/functional/ui/sign_spec.lua
+++ b/test/functional/ui/sign_spec.lua
@@ -12,7 +12,6 @@ describe('Signs', function()
before_each(function()
clear()
screen = Screen.new()
- screen:attach()
screen:add_extra_attr_ids {
[100] = { bold = true, foreground = Screen.colors.Magenta1 },
}
diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua
index c3e01e5b6a..86d5a362e5 100644
--- a/test/functional/ui/spell_spec.lua
+++ b/test/functional/ui/spell_spec.lua
@@ -17,7 +17,6 @@ describe("'spell'", function()
before_each(function()
clear()
screen = Screen.new(80, 8)
- screen:attach()
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
[1] = { special = Screen.colors.Red, undercurl = true },
diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua
index b225fa518d..268e7173e6 100644
--- a/test/functional/ui/statuscolumn_spec.lua
+++ b/test/functional/ui/statuscolumn_spec.lua
@@ -20,7 +20,6 @@ describe('statuscolumn', function()
before_each(function()
clear('--cmd', 'set number nuw=1 | call setline(1, repeat(["aaaaa"], 16)) | norm GM')
screen = Screen.new()
- screen:attach()
exec_lua('ns = vim.api.nvim_create_namespace("")')
end)
diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua
index d628d7b1d7..1d0f181244 100644
--- a/test/functional/ui/statusline_spec.lua
+++ b/test/functional/ui/statusline_spec.lua
@@ -27,7 +27,6 @@ for _, model in ipairs(mousemodels) do
screen:add_extra_attr_ids {
[100] = { bold = true, reverse = true, foreground = Screen.colors.Blue },
}
- screen:attach()
command('set laststatus=2 mousemodel=' .. model)
exec([=[
function! MyClickFunc(minwid, clicks, button, mods)
@@ -254,7 +253,6 @@ describe('global statusline', function()
before_each(function()
clear()
screen = Screen.new(60, 16)
- screen:attach()
screen:add_extra_attr_ids {
[100] = { foreground = Screen.colors.Magenta1, bold = true },
}
@@ -520,7 +518,6 @@ end)
it('statusline is redrawn with :resize from <Cmd> mapping #19629', function()
clear()
local screen = Screen.new(40, 8)
- screen:attach()
exec([[
set laststatus=2
nnoremap <Up> <cmd>resize -1<CR>
@@ -545,7 +542,6 @@ end)
it('showcmdloc=statusline does not show if statusline is too narrow', function()
clear()
local screen = Screen.new(40, 8)
- screen:attach()
command('set showcmd')
command('set showcmdloc=statusline')
command('1vsplit')
@@ -561,8 +557,7 @@ end)
it('K_EVENT does not trigger a statusline redraw unnecessarily', function()
clear()
- local screen = Screen.new(40, 8)
- screen:attach()
+ local _ = Screen.new(40, 8)
-- does not redraw on vim.schedule (#17937)
command([[
set laststatus=2
@@ -594,7 +589,6 @@ end)
it('statusline is redrawn on various state changes', function()
clear()
local screen = Screen.new(40, 4)
- screen:attach()
-- recording state change #22683
command('set ls=2 stl=%{repeat(reg_recording(),5)}')
@@ -660,7 +654,6 @@ end)
it('ruler is redrawn in cmdline with redrawstatus #22804', function()
clear()
local screen = Screen.new(40, 2)
- screen:attach()
command([[
let g:n = 'initial value'
set ls=1 ru ruf=%{g:n}
@@ -677,7 +670,6 @@ end)
it('shows correct ruler in cmdline with no statusline', function()
clear()
local screen = Screen.new(30, 8)
- screen:attach()
-- Use long ruler to check 'ruler' with 'rulerformat' set has correct width.
command [[
set ruler rulerformat=%{winnr()}longlonglong ls=0 winwidth=10
@@ -725,7 +717,6 @@ end)
it('uses "stl" and "stlnc" fillchars even if they are the same #19803', function()
clear()
local screen = Screen.new(53, 4)
- screen:attach()
command('hi clear StatusLine')
command('hi clear StatusLineNC')
command('vsplit')
@@ -742,7 +733,6 @@ end)
it('showcmdloc=statusline works with vertical splits', function()
clear()
local screen = Screen.new(53, 4)
- screen:attach()
command('rightbelow vsplit')
command('set showcmd showcmdloc=statusline')
feed('1234')
@@ -766,7 +756,6 @@ end)
it('keymap is shown with vertical splits #27269', function()
clear()
local screen = Screen.new(53, 4)
- screen:attach()
command('setlocal keymap=dvorak')
command('rightbelow vsplit')
screen:expect([[
diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua
index be35e9bf4f..57d76e54df 100644
--- a/test/functional/ui/syntax_conceal_spec.lua
+++ b/test/functional/ui/syntax_conceal_spec.lua
@@ -14,7 +14,6 @@ describe('Screen', function()
before_each(function()
clear()
screen = Screen.new(nil, 10)
- screen:attach()
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
[1] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray },
diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua
index de1e701101..4c6fd8fbda 100644
--- a/test/functional/ui/tabline_spec.lua
+++ b/test/functional/ui/tabline_spec.lua
@@ -13,8 +13,7 @@ describe('ui/ext_tabline', function()
before_each(function()
clear()
- screen = Screen.new(25, 5)
- screen:attach({ rgb = true, ext_tabline = true })
+ screen = Screen.new(25, 5, { rgb = true, ext_tabline = true })
function screen:_handle_tabline_update(curtab, tabs, curbuf, buffers)
event_curtab = curtab
event_tabs = tabs
@@ -100,7 +99,6 @@ describe('tabline', function()
before_each(function()
clear()
screen = Screen.new(42, 5)
- screen:attach()
end)
it('redraws when tabline option is set', function()
diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua
index 3189232957..66eb15478b 100644
--- a/test/functional/ui/title_spec.lua
+++ b/test/functional/ui/title_spec.lua
@@ -18,7 +18,6 @@ describe('title', function()
before_each(function()
clear()
screen = Screen.new()
- screen:attach()
end)
it('has correct default title with unnamed file', function()
diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua
index 4d01b7a779..94710bfb74 100644
--- a/test/functional/ui/wildmode_spec.lua
+++ b/test/functional/ui/wildmode_spec.lua
@@ -19,7 +19,6 @@ describe("'wildmenu'", function()
screen:add_extra_attr_ids {
[100] = { background = Screen.colors.Yellow1, foreground = Screen.colors.Black },
}
- screen:attach()
end)
-- oldtest: Test_wildmenu_screendump()
@@ -492,7 +491,6 @@ describe('command line completion', function()
screen:add_extra_attr_ids {
[100] = { background = Screen.colors.Yellow1, foreground = Screen.colors.Black },
}
- screen:attach()
end)
after_each(function()
os.remove('Xtest-functional-viml-compl-dir')
@@ -592,8 +590,7 @@ describe('ui/ext_wildmenu', function()
before_each(function()
clear()
- screen = Screen.new(25, 5)
- screen:attach({ rgb = true, ext_wildmenu = true })
+ screen = Screen.new(25, 5, { rgb = true, ext_wildmenu = true })
end)
it('works with :sign <tab>', function()
diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua
index bbdf3ad9ba..d1fd273dc1 100644
--- a/test/functional/ui/winbar_spec.lua
+++ b/test/functional/ui/winbar_spec.lua
@@ -18,7 +18,6 @@ describe('winbar', function()
before_each(function()
clear()
screen = Screen.new(60, 13)
- screen:attach()
screen:set_default_attr_ids({
[1] = { bold = true },
[2] = { reverse = true },
@@ -548,7 +547,6 @@ describe('local winbar with tabs', function()
before_each(function()
clear()
screen = Screen.new(60, 10)
- screen:attach()
api.nvim_set_option_value('winbar', 'foo', { scope = 'local', win = 0 })
end)
@@ -626,7 +624,6 @@ it('winbar works properly when redrawing is postponed #23534', function()
},
})
local screen = Screen.new(60, 6)
- screen:attach()
screen:expect([[
{5:(winbar) }|
^ |