neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 7d771c3eeef5b4dca9ebc5ed6f7ca03f2b26b6bc
parent 40dee8a2dcba996badaa6182eb34fde1694f92a3
Author: bfredl <bjorn.linse@gmail.com>
Date:   Thu, 14 Nov 2024 13:10:32 +0100

Merge pull request #31168 from bfredl/noattach

fix(tests): needing two calls to setup a screen is cringe
Diffstat:
Mtest/functional/api/buffer_spec.lua | 5-----
Mtest/functional/api/extmark_spec.lua | 10+---------
Mtest/functional/api/menu_spec.lua | 1-
Mtest/functional/api/ui_spec.lua | 8++------
Mtest/functional/api/vim_spec.lua | 23++---------------------
Mtest/functional/api/window_spec.lua | 6------
Mtest/functional/autocmd/autocmd_oldtest_spec.lua | 1-
Mtest/functional/autocmd/autocmd_spec.lua | 3---
Mtest/functional/autocmd/cmdline_spec.lua | 1-
Mtest/functional/autocmd/show_spec.lua | 1-
Mtest/functional/autocmd/win_scrolled_resized_spec.lua | 4+---
Mtest/functional/core/fileio_spec.lua | 2--
Mtest/functional/core/job_spec.lua | 4----
Mtest/functional/core/main_spec.lua | 1-
Mtest/functional/core/startup_spec.lua | 14+-------------
Mtest/functional/editor/completion_spec.lua | 1-
Mtest/functional/editor/ctrl_c_spec.lua | 1-
Mtest/functional/editor/defaults_spec.lua | 3---
Mtest/functional/editor/jump_spec.lua | 6------
Mtest/functional/editor/mark_spec.lua | 4----
Mtest/functional/editor/mode_cmdline_spec.lua | 2--
Mtest/functional/editor/mode_insert_spec.lua | 24+++++++-----------------
Mtest/functional/editor/mode_normal_spec.lua | 2--
Mtest/functional/editor/put_spec.lua | 1-
Mtest/functional/editor/tabpage_spec.lua | 1-
Mtest/functional/ex_cmds/append_spec.lua | 1-
Mtest/functional/ex_cmds/cmd_map_spec.lua | 1-
Mtest/functional/ex_cmds/debug_spec.lua | 1-
Mtest/functional/ex_cmds/digraphs_spec.lua | 1-
Mtest/functional/ex_cmds/drop_spec.lua | 1-
Mtest/functional/ex_cmds/highlight_spec.lua | 5+----
Mtest/functional/ex_cmds/map_spec.lua | 1-
Mtest/functional/ex_cmds/mksession_spec.lua | 6++----
Mtest/functional/ex_cmds/oldfiles_spec.lua | 1-
Mtest/functional/ex_cmds/quickfix_commands_spec.lua | 2--
Mtest/functional/ex_cmds/swapfile_preserve_recover_spec.lua | 4----
Mtest/functional/example_spec.lua | 4+---
Mtest/functional/legacy/063_match_and_matchadd_spec.lua | 1-
Mtest/functional/legacy/107_adjust_window_and_contents_spec.lua | 1-
Mtest/functional/legacy/arglist_spec.lua | 1-
Mtest/functional/legacy/breakindent_spec.lua | 2--
Mtest/functional/legacy/cmdline_spec.lua | 8--------
Mtest/functional/legacy/conceal_spec.lua | 10----------
Mtest/functional/legacy/cpoptions_spec.lua | 1-
Mtest/functional/legacy/debugger_spec.lua | 1-
Mtest/functional/legacy/digraph_spec.lua | 1-
Mtest/functional/legacy/display_spec.lua | 5-----
Mtest/functional/legacy/edit_spec.lua | 2--
Mtest/functional/legacy/ex_mode_spec.lua | 2--
Mtest/functional/legacy/excmd_spec.lua | 1-
Mtest/functional/legacy/fold_spec.lua | 1-
Mtest/functional/legacy/global_spec.lua | 1-
Mtest/functional/legacy/highlight_spec.lua | 2--
Mtest/functional/legacy/listchars_spec.lua | 1-
Mtest/functional/legacy/listlbr_spec.lua | 1-
Mtest/functional/legacy/listlbr_utf8_spec.lua | 1-
Mtest/functional/legacy/mapping_spec.lua | 1-
Mtest/functional/legacy/match_spec.lua | 4----
Mtest/functional/legacy/matchparen_spec.lua | 5-----
Mtest/functional/legacy/messages_spec.lua | 9---------
Mtest/functional/legacy/move_spec.lua | 1-
Mtest/functional/legacy/normal_spec.lua | 1-
Mtest/functional/legacy/number_spec.lua | 4----
Mtest/functional/legacy/options_spec.lua | 7++-----
Mtest/functional/legacy/prompt_buffer_spec.lua | 5-----
Mtest/functional/legacy/put_spec.lua | 2--
Mtest/functional/legacy/scroll_opt_spec.lua | 1-
Mtest/functional/legacy/search_spec.lua | 3---
Mtest/functional/legacy/search_stat_spec.lua | 1-
Mtest/functional/legacy/signs_spec.lua | 1-
Mtest/functional/legacy/source_spec.lua | 1-
Mtest/functional/legacy/statusline_spec.lua | 1-
Mtest/functional/legacy/substitute_spec.lua | 1-
Mtest/functional/legacy/tabline_spec.lua | 1-
Mtest/functional/legacy/vimscript_spec.lua | 2--
Mtest/functional/legacy/visual_spec.lua | 1-
Mtest/functional/legacy/window_cmd_spec.lua | 2--
Mtest/functional/lua/buffer_updates_spec.lua | 1-
Mtest/functional/lua/commands_spec.lua | 2--
Mtest/functional/lua/hl_spec.lua | 1-
Mtest/functional/lua/loop_spec.lua | 1-
Mtest/functional/lua/luaeval_spec.lua | 1-
Mtest/functional/lua/overrides_spec.lua | 2--
Mtest/functional/lua/secure_spec.lua | 1-
Mtest/functional/lua/thread_spec.lua | 2--
Mtest/functional/lua/ui_event_spec.lua | 4+---
Mtest/functional/lua/vim_spec.lua | 8--------
Mtest/functional/lua/with_spec.lua | 2--
Mtest/functional/options/belloff_spec.lua | 1-
Mtest/functional/options/chars_spec.lua | 2--
Mtest/functional/options/cursorbind_spec.lua | 1-
Mtest/functional/options/defaults_spec.lua | 2--
Mtest/functional/options/shortmess_spec.lua | 1-
Mtest/functional/plugin/health_spec.lua | 10+++-------
Mtest/functional/plugin/lsp/inlay_hint_spec.lua | 2--
Mtest/functional/plugin/lsp/semantic_tokens_spec.lua | 1-
Mtest/functional/plugin/lsp/utils_spec.lua | 4+---
Mtest/functional/plugin/man_spec.lua | 1-
Mtest/functional/plugin/matchparen_spec.lua | 1-
Mtest/functional/plugin/shada_spec.lua | 1-
Mtest/functional/plugin/tohtml_spec.lua | 3+--
Mtest/functional/plugin/tutor_spec.lua | 1-
Mtest/functional/plugin/vim_syntax_spec.lua | 1-
Mtest/functional/provider/clipboard_spec.lua | 4----
Mtest/functional/terminal/buffer_spec.lua | 3---
Mtest/functional/terminal/channel_spec.lua | 4----
Mtest/functional/terminal/cursor_spec.lua | 3+--
Mtest/functional/terminal/edit_spec.lua | 10++--------
Mtest/functional/terminal/ex_terminal_spec.lua | 6++----
Mtest/functional/terminal/highlight_spec.lua | 12+++---------
Mtest/functional/terminal/scrollback_spec.lua | 4+---
Mtest/functional/terminal/tui_spec.lua | 2--
Mtest/functional/terminal/window_split_tab_spec.lua | 4----
Mtest/functional/testterm.lua | 4+---
Mtest/functional/treesitter/fold_spec.lua | 4----
Mtest/functional/treesitter/highlight_spec.lua | 6------
Mtest/functional/ui/bufhl_spec.lua | 1-
Mtest/functional/ui/cmdline_highlight_spec.lua | 1-
Mtest/functional/ui/cmdline_spec.lua | 22++++++----------------
Mtest/functional/ui/cursor_spec.lua | 1-
Mtest/functional/ui/decorations_spec.lua | 7-------
Mtest/functional/ui/diff_spec.lua | 10----------
Mtest/functional/ui/embed_spec.lua | 17+++++++----------
Mtest/functional/ui/float_spec.lua | 8++------
Mtest/functional/ui/fold_spec.lua | 3+--
Mtest/functional/ui/highlight_spec.lua | 39++++++---------------------------------
Mtest/functional/ui/hlstate_spec.lua | 7+------
Mtest/functional/ui/inccommand_spec.lua | 13+++++--------
Mtest/functional/ui/inccommand_user_spec.lua | 2--
Mtest/functional/ui/input_spec.lua | 3---
Mtest/functional/ui/linematch_spec.lua | 4----
Mtest/functional/ui/messages_spec.lua | 17+++++------------
Mtest/functional/ui/mode_spec.lua | 3+--
Mtest/functional/ui/mouse_spec.lua | 1-
Mtest/functional/ui/multibyte_spec.lua | 4+---
Mtest/functional/ui/multigrid_spec.lua | 3+--
Mtest/functional/ui/options_spec.lua | 10+++-------
Mtest/functional/ui/output_spec.lua | 3---
Mtest/functional/ui/popupmenu_spec.lua | 10+++-------
Mtest/functional/ui/quickfix_spec.lua | 1-
Mtest/functional/ui/screen.lua | 89++++++++++++++++++++++++++++++++++---------------------------------------------
Mtest/functional/ui/screen_basic_spec.lua | 10++--------
Mtest/functional/ui/scrollbind_spec.lua | 1-
Mtest/functional/ui/searchhl_spec.lua | 1-
Mtest/functional/ui/sign_spec.lua | 1-
Mtest/functional/ui/spell_spec.lua | 1-
Mtest/functional/ui/statuscolumn_spec.lua | 1-
Mtest/functional/ui/statusline_spec.lua | 13+------------
Mtest/functional/ui/syntax_conceal_spec.lua | 1-
Mtest/functional/ui/tabline_spec.lua | 4+---
Mtest/functional/ui/title_spec.lua | 1-
Mtest/functional/ui/wildmode_spec.lua | 5+----
Mtest/functional/ui/winbar_spec.lua | 3---
Mtest/functional/vimscript/api_functions_spec.lua | 3---
Mtest/functional/vimscript/eval_spec.lua | 7++-----
Mtest/functional/vimscript/execute_spec.lua | 4----
Mtest/functional/vimscript/has_spec.lua | 9+++++----
Mtest/functional/vimscript/input_spec.lua | 1-
Mtest/functional/vimscript/match_functions_spec.lua | 1-
Mtest/functional/vimscript/system_spec.lua | 8--------
Mtest/functional/vimscript/timer_spec.lua | 3---
161 files changed, 128 insertions(+), 606 deletions(-)

diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua @@ -125,7 +125,6 @@ describe('api/buf', function() it('cursor position is maintained consistently with viewport', function() local screen = Screen.new(20, 12) - screen:attach() local lines = { 'line1', 'line2', 'line3', 'line4', 'line5', 'line6' } local buf = api.nvim_get_current_buf() @@ -211,7 +210,6 @@ describe('api/buf', function() local screen before_each(function() screen = Screen.new(20, 12) - screen:attach() api.nvim_buf_set_lines( 0, 0, @@ -735,7 +733,6 @@ describe('api/buf', function() it("set_lines of invisible buffer doesn't move cursor in current window", function() local screen = Screen.new(20, 5) - screen:attach() insert([[ Who would win? @@ -1689,7 +1686,6 @@ describe('api/buf', function() it('correctly marks changed region for redraw #13890', function() local screen = Screen.new(20, 5) - screen:attach() insert([[ AAA @@ -1742,7 +1738,6 @@ describe('api/buf', function() local screen before_each(function() screen = Screen.new(20, 12) - screen:attach() api.nvim_buf_set_lines( 0, 0, diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua @@ -455,7 +455,6 @@ describe('API/extmarks', function() it('join works when no marks are present', function() screen = Screen.new(15, 10) - screen:attach() feed('a<cr>1<esc>') feed('kJ') -- This shouldn't seg fault @@ -508,7 +507,6 @@ describe('API/extmarks', function() it('marks move with char inserts', function() -- insertchar in edit.c (the ins_str branch) screen = Screen.new(15, 10) - screen:attach() set_extmark(ns, marks[1], 0, 3) feed('0') insert('abc') @@ -1726,7 +1724,6 @@ describe('API/extmarks', function() it('invalidated marks are deleted', function() screen = Screen.new(40, 6) - screen:attach() feed('dd6iaaa bbb ccc<CR><ESC>gg') api.nvim_set_option_value('signcolumn', 'auto:2', {}) set_extmark(ns, 1, 0, 0, { invalidate = true, sign_text = 'S1', end_row = 1 }) @@ -1811,7 +1808,6 @@ describe('API/extmarks', function() it('respects priority', function() screen = Screen.new(15, 10) - screen:attach() set_extmark(ns, marks[1], 0, 0, { hl_group = 'Comment', @@ -1983,7 +1979,6 @@ describe('API/win_extmark', function() it('sends and only sends ui-watched marks to ui', function() screen = Screen.new(20, 4) - screen:attach() -- should send this set_extmark(ns, marks[1], 1, 0, { ui_watched = true }) -- should not send this @@ -2006,7 +2001,6 @@ describe('API/win_extmark', function() it('sends multiple ui-watched marks to ui', function() screen = Screen.new(20, 4) - screen:attach() feed('15A!<Esc>') -- should send all of these set_extmark(ns, marks[1], 1, 0, { ui_watched = true, virt_text_pos = 'overlay' }) @@ -2052,7 +2046,6 @@ describe('API/win_extmark', function() it('updates ui-watched marks', function() screen = Screen.new(20, 4) - screen:attach() -- should send this set_extmark(ns, marks[1], 1, 0, { ui_watched = true }) -- should not send this @@ -2096,8 +2089,7 @@ describe('API/win_extmark', function() end) it('sends ui-watched to splits', function() - screen = Screen.new(20, 8) - screen:attach({ ext_multigrid = true }) + screen = Screen.new(20, 8, { ext_multigrid = true }) -- should send this set_extmark(ns, marks[1], 1, 0, { ui_watched = true }) -- should not send this diff --git a/test/functional/api/menu_spec.lua b/test/functional/api/menu_spec.lua @@ -11,7 +11,6 @@ describe('update_menu notification', function() before_each(function() clear() screen = Screen.new() - screen:attach() end) local function expect_sent(expected) diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua @@ -18,8 +18,7 @@ describe('nvim_ui_attach()', function() end) it('handles very large width/height #2180', function() - local screen = Screen.new(999, 999) - screen:attach() + local _ = Screen.new(999, 999) eq(999, eval('&lines')) eq(999, eval('&columns')) end) @@ -64,8 +63,7 @@ describe('nvim_ui_attach()', function() eq('UI not attached to channel: 1', pcall_err(request, 'nvim_ui_set_option', 'rgb', true)) eq('UI not attached to channel: 1', pcall_err(request, 'nvim_ui_detach')) - local screen = Screen.new() - screen:attach({ rgb = false }) + local _ = Screen.new(nil, nil, { rgb = false }) eq( 'UI already attached to channel: 1', pcall_err(request, 'nvim_ui_attach', 40, 10, { rgb = false }) @@ -82,7 +80,6 @@ it('autocmds UIEnter/UILeave', function() autocmd VimEnter * call add(g:evs, "VimEnter") ]]) local screen = Screen.new() - screen:attach() eq({ chan = 1 }, eval('g:uienter_ev')) screen:detach() eq({ chan = 1 }, eval('g:uileave_ev')) @@ -96,7 +93,6 @@ end) it('autocmds VimSuspend/VimResume #22041', function() clear() local screen = Screen.new() - screen:attach() exec([[ let g:ev = [] autocmd VimResume * :call add(g:ev, 'r') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua @@ -366,7 +366,6 @@ describe('API', function() it('displays messages when opts.output=false', function() local screen = Screen.new(40, 8) - screen:attach() api.nvim_exec2("echo 'hello'", { output = false }) screen:expect { grid = [[ @@ -379,7 +378,6 @@ describe('API', function() it("doesn't display messages when output=true", function() local screen = Screen.new(40, 6) - screen:attach() api.nvim_exec2("echo 'hello'", { output = true }) screen:expect { grid = [[ @@ -1278,7 +1276,6 @@ describe('API', function() end) it('pasting with empty last chunk in Cmdline mode', function() local screen = Screen.new(20, 4) - screen:attach() feed(':') api.nvim_paste('Foo', true, 1) api.nvim_paste('', true, 3) @@ -1290,7 +1287,6 @@ describe('API', function() end) it('pasting text with control characters in Cmdline mode', function() local screen = Screen.new(20, 4) - screen:attach() feed(':') api.nvim_paste('normal! \023\022\006\027', true, -1) screen:expect([[ @@ -1675,7 +1671,6 @@ describe('API', function() eq({ 1, 5 }, api.nvim_win_get_cursor(0)) local screen = Screen.new(60, 3) - screen:attach() eq(1, eval('v:hlsearch')) screen:expect { grid = [[ @@ -2130,7 +2125,6 @@ describe('API', function() it('does not complete ("interrupt") `d` #3732', function() local screen = Screen.new(20, 4) - screen:attach() command('set listchars=eol:$') command('set list') feed('ia<cr>b<cr>c<cr><Esc>kkk') @@ -2391,7 +2385,6 @@ describe('API', function() before_each(function() screen = Screen.new(40, 8) - screen:attach() end) it('prints long messages correctly #20534', function() @@ -2461,7 +2454,6 @@ describe('API', function() before_each(function() screen = Screen.new(40, 8) - screen:attach() end) it('can show one line', function() @@ -2543,7 +2535,6 @@ describe('API', function() before_each(function() screen = Screen.new(40, 8) - screen:attach() end) it('shows only one return prompt after all lines are shown', function() @@ -3100,8 +3091,7 @@ describe('API', function() eq({}, api.nvim_list_uis()) end) it('returns attached UIs', function() - local screen = Screen.new(20, 4) - screen:attach({ override = true }) + local screen = Screen.new(20, 4, { override = true }) local expected = { { chan = 1, @@ -3129,8 +3119,7 @@ describe('API', function() eq(expected, api.nvim_list_uis()) screen:detach() - screen = Screen.new(44, 99) - screen:attach({ rgb = false }) + screen = Screen.new(44, 99, { rgb = false }) -- luacheck: ignore expected[1].rgb = false expected[1].override = false expected[1].width = 44 @@ -3165,7 +3154,6 @@ describe('API', function() eq(1, api.nvim_get_current_buf()) local screen = Screen.new(20, 4) - screen:attach() api.nvim_buf_set_lines(2, 0, -1, true, { 'some text' }) api.nvim_set_current_buf(2) screen:expect( @@ -3229,7 +3217,6 @@ describe('API', function() eq(1, api.nvim_get_current_buf()) local screen = Screen.new(20, 4) - screen:attach() -- -- Editing a scratch-buffer does NOT change its properties. @@ -3591,7 +3578,6 @@ describe('API', function() before_each(function() screen = Screen.new(40, 8) - screen:attach() command('highlight Statement gui=bold guifg=Brown') command('highlight Special guifg=SlateBlue') end) @@ -3654,7 +3640,6 @@ describe('API', function() before_each(function() screen = Screen.new(100, 35) - screen:attach() screen:add_extra_attr_ids { [100] = { background = tonumber('0xffff40'), bg_indexed = true }, [101] = { @@ -3933,7 +3918,6 @@ describe('API', function() command('set readonly') eq({ str = '[RO]', width = 4 }, api.nvim_eval_statusline('%r', { maxwidth = 5 })) local screen = Screen.new(80, 24) - screen:attach() command('set showcmd') feed('1234') screen:expect({ any = '1234' }) @@ -4591,7 +4575,6 @@ describe('API', function() end) it('does not interfere with printing line in Ex mode #19400', function() local screen = Screen.new(60, 7) - screen:attach() insert([[ foo bar]]) @@ -5048,7 +5031,6 @@ describe('API', function() it("doesn't display messages when output=true", function() local screen = Screen.new(40, 6) - screen:attach() api.nvim_cmd({ cmd = 'echo', args = { [['hello']] } }, { output = true }) screen:expect { grid = [[ @@ -5131,7 +5113,6 @@ describe('API', function() it('nvim__redraw', function() local screen = Screen.new(60, 5) - screen:attach() eq('at least one action required', pcall_err(api.nvim__redraw, {})) eq('at least one action required', pcall_err(api.nvim__redraw, { buf = 0 })) eq('at least one action required', pcall_err(api.nvim__redraw, { win = 0 })) diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua @@ -170,7 +170,6 @@ describe('API/win', function() it('updates the screen, and also when the window is unfocused', function() local screen = Screen.new(30, 9) - screen:attach() insert('prologue') feed('100o<esc>') @@ -281,7 +280,6 @@ describe('API/win', function() it('updates cursorline and statusline ruler in non-current window', function() local screen = Screen.new(60, 8) - screen:attach() command('set ruler') command('set cursorline') insert([[ @@ -314,7 +312,6 @@ describe('API/win', function() it('updates cursorcolumn in non-current window', function() local screen = Screen.new(60, 8) - screen:attach() command('set cursorcolumn') insert([[ aaa @@ -857,7 +854,6 @@ describe('API/win', function() it('with two diff windows', function() local X = api.nvim_get_vvar('maxcol') local screen = Screen.new(45, 22) - screen:attach() exec([[ set diffopt+=context:2 number let expr = 'printf("%08d", v:val) .. repeat("!", v:val)' @@ -975,7 +971,6 @@ describe('API/win', function() it('with wrapped lines', function() local X = api.nvim_get_vvar('maxcol') local screen = Screen.new(45, 22) - screen:attach() exec([[ set number cpoptions+=n call setline(1, repeat([repeat('foobar-', 36)], 3)) @@ -2557,7 +2552,6 @@ describe('API/win', function() it('updates statusline when moving bottom split', function() local screen = Screen.new(10, 10) - screen:attach() exec([[ set laststatus=0 belowright split diff --git a/test/functional/autocmd/autocmd_oldtest_spec.lua b/test/functional/autocmd/autocmd_oldtest_spec.lua @@ -102,7 +102,6 @@ describe('oldtests', function() -- oldtest: Test_delete_ml_get_errors() it('no ml_get error with TextChanged autocommand and delete', function() local screen = Screen.new(75, 10) - screen:attach() screen:add_extra_attr_ids { [100] = { background = Screen.colors.Cyan1 }, } diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua @@ -258,7 +258,6 @@ describe('autocmd', function() -- Check redrawing and API accesses to this window. local screen = Screen.new(50, 10) - screen:attach() source([[ function! Doit() @@ -333,7 +332,6 @@ describe('autocmd', function() it('`aucmd_win` cannot be changed into a normal window #13699', function() local screen = Screen.new(50, 10) - screen:attach() -- Create specific layout and ensure it's left unchanged. -- Use vim._with on a hidden buffer so aucmd_win is used. @@ -498,7 +496,6 @@ describe('autocmd', function() it(':doautocmd does not warn "No matching autocommands" #10689', function() local screen = Screen.new(32, 3) - screen:attach() feed(':doautocmd User Foo<cr>') screen:expect { diff --git a/test/functional/autocmd/cmdline_spec.lua b/test/functional/autocmd/cmdline_spec.lua @@ -60,7 +60,6 @@ describe('cmdline autocommands', function() it('handles errors correctly', function() clear() local screen = Screen.new(72, 8) - screen:attach() command("autocmd CmdlineEnter * echoerr 'FAIL'") command("autocmd CmdlineLeave * echoerr 'very error'") diff --git a/test/functional/autocmd/show_spec.lua b/test/functional/autocmd/show_spec.lua @@ -46,7 +46,6 @@ describe(':autocmd', function() screen:add_extra_attr_ids { [100] = { foreground = Screen.colors.Magenta, bold = true }, } - screen:attach() exec([[ set more autocmd! BufEnter diff --git a/test/functional/autocmd/win_scrolled_resized_spec.lua b/test/functional/autocmd/win_scrolled_resized_spec.lua @@ -225,8 +225,7 @@ end) describe('WinScrolled', function() -- oldtest: Test_WinScrolled_mouse() it('is triggered by mouse scrolling in another window', function() - local screen = Screen.new(75, 10) - screen:attach() + local _ = Screen.new(75, 10) exec([[ set nowrap scrolloff=0 set mouse=a @@ -304,7 +303,6 @@ describe('WinScrolled', function() it('is triggered by mouse scrolling in unfocused floating window #18222', function() local screen = Screen.new(80, 24) - screen:attach() exec([[ let g:scrolled = 0 diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua @@ -59,7 +59,6 @@ describe('fileio', function() local screen_nvim = spawn(argv) set_session(screen_nvim) local screen = Screen.new(70, 10) - screen:attach() screen:set_default_attr_ids({ [1] = { foreground = Screen.colors.NvimDarkGrey4 }, [2] = { background = Screen.colors.NvimDarkGrey1, foreground = Screen.colors.NvimLightGrey3 }, @@ -276,7 +275,6 @@ describe('fileio', function() write_file('Xtest-overwrite-forced', 'foobar') command('set nofixendofline') local screen = Screen.new(40, 4) - screen:attach() command('set shortmess-=F') command('e Xtest-overwrite-forced') diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua @@ -498,7 +498,6 @@ describe('jobs', function() it('can redefine callbacks being used by a job', function() local screen = Screen.new() - screen:attach() screen:set_default_attr_ids({ [1] = { bold = true, foreground = Screen.colors.Blue }, }) @@ -524,7 +523,6 @@ describe('jobs', function() it('requires funcrefs for script-local (s:) functions', function() local screen = Screen.new(60, 5) - screen:attach() screen:set_default_attr_ids({ [1] = { bold = true, foreground = Screen.colors.Blue1 }, [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, @@ -910,7 +908,6 @@ describe('jobs', function() it('hides cursor and flushes messages before blocking', function() local screen = Screen.new(50, 6) - screen:attach() command([[let g:id = jobstart([v:progpath, '--clean', '--headless'])]]) source([[ func PrintAndWait() @@ -1223,7 +1220,6 @@ describe('pty process teardown', function() before_each(function() clear() screen = Screen.new(30, 6) - screen:attach() screen:expect([[ ^ | {1:~ }|*4 diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua @@ -89,7 +89,6 @@ describe('command-line option', function() it('does not crash after reading from stdin in non-headless mode', function() skip(is_os('win')) local screen = Screen.new(40, 8) - screen:attach() local args = { nvim_prog_abs(), '-u', diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua @@ -55,7 +55,6 @@ describe('startup', function() clear() local screen screen = Screen.new(84, 3) - screen:attach() fn.termopen({ nvim_prog, '-u', 'NONE', '--server', eval('v:servername'), '--remote-ui' }) screen:expect([[ ^Cannot attach UI of :terminal child to its parent. (Unset $NVIM to skip this check) | @@ -97,7 +96,6 @@ describe('startup', function() clear() local screen screen = Screen.new(60, 7) - screen:attach() -- not the same colors on windows for some reason screen._default_attr_ids = nil local id = fn.termopen({ @@ -346,7 +344,6 @@ describe('startup', function() it('with --embed: has("ttyin")==0 has("ttyout")==0', function() local screen = Screen.new(25, 3) -- Remote UI connected by --embed. - screen:attach() -- TODO: a lot of tests in this file already use the new default color scheme. -- once we do the batch update of tests to use it, remove this workarond screen._default_attr_ids = nil @@ -360,7 +357,6 @@ describe('startup', function() it('in a TTY: has("ttyin")==1 has("ttyout")==1', function() local screen = Screen.new(25, 4) - screen:attach() screen._default_attr_ids = nil if is_os('win') then command([[set shellcmdflag=/s\ /c shellxquote=\"]]) @@ -455,7 +451,6 @@ describe('startup', function() it('input from pipe (implicit) #7679', function() clear({ env = { NVIM_LOG_FILE = testlog } }) local screen = Screen.new(25, 4) - screen:attach() screen._default_attr_ids = nil if is_os('win') then command([[set shellcmdflag=/s\ /c shellxquote=\"]]) @@ -620,7 +615,6 @@ describe('startup', function() it('ENTER dismisses early message #7967', function() local screen screen = Screen.new(60, 6) - screen:attach() screen._default_attr_ids = nil local id = fn.termopen({ nvim_prog, @@ -718,7 +712,6 @@ describe('startup', function() it('-e/-E interactive #7679', function() clear('-e') local screen = Screen.new(25, 3) - screen:attach() feed("put ='from -e'<CR>") screen:expect([[ :put ='from -e' | @@ -728,7 +721,6 @@ describe('startup', function() clear('-E') screen = Screen.new(25, 3) - screen:attach() feed("put ='from -E'<CR>") screen:expect([[ :put ='from -E' | @@ -738,9 +730,8 @@ describe('startup', function() end) it('-e sets ex mode', function() - local screen = Screen.new(25, 3) clear('-e') - screen:attach() + local screen = Screen.new(25, 3) -- Verify we set the proper mode both before and after :vi. feed('put =mode(1)<CR>vi<CR>:put =mode(1)<CR>') screen:expect([[ @@ -792,7 +783,6 @@ describe('startup', function() it("sets 'shortmess' when loading other tabs", function() clear({ args = { '-p', 'a', 'b', 'c' } }) local screen = Screen.new(25, 4) - screen:attach() screen:expect({ grid = [[ {1: a }{2: b c }{3: }{2:X}| @@ -1155,7 +1145,6 @@ describe('user config init', function() eq('---', eval('g:exrc_file')) local screen = Screen.new(50, 8) - screen:attach() screen._default_attr_ids = nil fn.termopen({ nvim_prog }, { env = { @@ -1431,7 +1420,6 @@ describe('inccommand on ex mode', function() clear() local screen screen = Screen.new(60, 10) - screen:attach() local id = fn.termopen({ nvim_prog, '-u', diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua @@ -17,7 +17,6 @@ describe('completion', function() before_each(function() clear() screen = Screen.new(60, 8) - screen:attach() screen:add_extra_attr_ids { [100] = { foreground = Screen.colors.Gray0, background = Screen.colors.Yellow }, [101] = { background = Screen.colors.Gray0 }, diff --git a/test/functional/editor/ctrl_c_spec.lua b/test/functional/editor/ctrl_c_spec.lua @@ -13,7 +13,6 @@ describe('CTRL-C (mapped)', function() before_each(function() clear() screen = Screen.new(52, 6) - screen:attach() end) it('interrupts :global', function() diff --git a/test/functional/editor/defaults_spec.lua b/test/functional/editor/defaults_spec.lua @@ -35,7 +35,6 @@ describe('default', function() args = { '+autocmd! nvim_popupmenu', '+aunmenu PopUp' }, } local screen = Screen.new(40, 8) - screen:attach() n.insert([[ 1 line 1 2 https://example.com @@ -58,7 +57,6 @@ describe('default', function() it('right-click on URL shows "Open in web browser"', function() n.clear() local screen = Screen.new(40, 8) - screen:attach() n.insert([[ 1 line 1 2 https://example.com @@ -100,7 +98,6 @@ describe('default', function() it('do not show a full stack trace #30625', function() n.clear({ args_rm = { '--cmd' } }) local screen = Screen.new(40, 8) - screen:attach() screen:set_default_attr_ids({ [1] = { foreground = Screen.colors.NvimDarkGray4 }, [2] = { diff --git a/test/functional/editor/jump_spec.lua b/test/functional/editor/jump_spec.lua @@ -56,7 +56,6 @@ describe('jumplist', function() write_file(fname2, 'baz') local screen = Screen.new(5, 25) - screen:attach() command('set number') command('edit ' .. fname1) feed('35gg') @@ -386,7 +385,6 @@ describe('jumpoptions=view', function() it('restores the view', function() local screen = Screen.new(5, 8) - screen:attach() command('edit ' .. file1) feed('12Gztj') feed('gg<C-o>') @@ -404,7 +402,6 @@ describe('jumpoptions=view', function() it('restores the view across files', function() local screen = Screen.new(5, 5) - screen:attach() command('args ' .. file1 .. ' ' .. file2) feed('12Gzt') command('next') @@ -428,7 +425,6 @@ describe('jumpoptions=view', function() it('restores the view across files with <C-^>', function() local screen = Screen.new(5, 5) - screen:attach() command('args ' .. file1 .. ' ' .. file2) feed('12Gzt') command('next') @@ -452,7 +448,6 @@ describe('jumpoptions=view', function() it("falls back to standard behavior when view can't be recovered", function() local screen = Screen.new(5, 8) - screen:attach() command('edit ' .. file1) feed('7GzbG') api.nvim_buf_set_lines(0, 0, 2, true, {}) @@ -477,7 +472,6 @@ describe('jumpoptions=view', function() it('falls back to standard behavior for a mark without a view', function() local screen = Screen.new(5, 8) - screen:attach() command('edit ' .. file1) feed('10ggzzvwy') screen:expect([[ diff --git a/test/functional/editor/mark_spec.lua b/test/functional/editor/mark_spec.lua @@ -348,7 +348,6 @@ describe('named marks view', function() it('is restored in normal mode but not op-pending mode', function() local screen = Screen.new(5, 8) - screen:attach() command('edit ' .. file1) feed('<C-e>jWma') feed("G'a") @@ -390,7 +389,6 @@ describe('named marks view', function() it('is restored across files', function() local screen = Screen.new(5, 5) - screen:attach() command('args ' .. file1 .. ' ' .. file2) feed('<C-e>mA') local mark_view = [[ @@ -415,7 +413,6 @@ describe('named marks view', function() it("fallback to standard behavior when view can't be recovered", function() local screen = Screen.new(10, 10) - screen:attach() command('edit ' .. file1) feed('7GzbmaG') -- Seven lines from the top command('new') -- Screen size for window is now half the height can't be restored @@ -434,7 +431,6 @@ describe('named marks view', function() it('fallback to standard behavior when mark is loaded from shada', function() local screen = Screen.new(10, 6) - screen:attach() command('edit ' .. file1) feed('G') feed('mA') diff --git a/test/functional/editor/mode_cmdline_spec.lua b/test/functional/editor/mode_cmdline_spec.lua @@ -44,7 +44,6 @@ describe('cmdline', function() -- 'arabicshape' cheats and always redraws everything which trivially works, -- this test is for partial redraws in 'noarabicshape' mode. command('set noarabicshape') - screen:attach() fn.setreg('a', '💻') feed(':test 🧑‍') screen:expect([[ @@ -69,7 +68,6 @@ describe('cmdline', function() it('redraws statusline when toggling overstrike', function() local screen = Screen.new(60, 4) - screen:attach() command('set laststatus=2 statusline=%!mode(1)') feed(':') screen:expect { diff --git a/test/functional/editor/mode_insert_spec.lua b/test/functional/editor/mode_insert_spec.lua @@ -55,7 +55,6 @@ describe('insert-mode', function() it('double quote is removed after hit-enter prompt #22609', function() local screen = Screen.new(50, 6) - screen:attach() feed('i<C-R>') screen:expect([[ {18:^"} | @@ -180,7 +179,6 @@ describe('insert-mode', function() it('multi-char mapping updates screen properly #25626', function() local screen = Screen.new(60, 6) - screen:attach() command('vnew') insert('foo\nfoo\nfoo') command('wincmd w') @@ -228,8 +226,7 @@ describe('insert-mode', function() end it('works with tabs and spaces', function() - local screen = Screen.new(30, 2) - screen:attach() + local _ = Screen.new(30, 2) command('setl ts=4 sw=4') set_lines(0, 1, '\t' .. s(4) .. '\t' .. s(9) .. '\t a') feed('$i') @@ -246,8 +243,7 @@ describe('insert-mode', function() end) it('works with varsofttabstop', function() - local screen = Screen.new(30, 2) - screen:attach() + local _ = Screen.new(30, 2) command('setl vsts=6,2,5,3') set_lines(0, 1, 'a\t' .. s(4) .. '\t a') feed('$i') @@ -263,8 +259,7 @@ describe('insert-mode', function() end) it('works with tab as ^I', function() - local screen = Screen.new(30, 2) - screen:attach() + local _ = Screen.new(30, 2) command('set list listchars=space:.') command('setl ts=4 sw=4') set_lines(0, 1, '\t' .. s(4) .. '\t' .. s(9) .. '\t a') @@ -280,8 +275,7 @@ describe('insert-mode', function() end) it('works in replace mode', function() - local screen = Screen.new(50, 2) - screen:attach() + local _ = Screen.new(50, 2) command('setl ts=8 sw=8 sts=8') set_lines(0, 1, '\t' .. s(4) .. '\t' .. s(9) .. '\t a') feed('$R') @@ -296,8 +290,7 @@ describe('insert-mode', function() end) it('works with breakindent', function() - local screen = Screen.new(17, 4) - screen:attach() + local _ = Screen.new(17, 4) command('setl ts=4 sw=4 bri briopt=min:5') set_lines(0, 1, '\t' .. s(4) .. '\t' .. s(9) .. '\t a') feed('$i') @@ -314,8 +307,7 @@ describe('insert-mode', function() end) it('works with inline virtual text', function() - local screen = Screen.new(50, 2) - screen:attach() + local _ = Screen.new(50, 2) command('setl ts=4 sw=4') set_lines(0, 1, '\t' .. s(4) .. '\t' .. s(9) .. '\t a') local ns = api.nvim_create_namespace('') @@ -335,8 +327,7 @@ describe('insert-mode', function() end) it("works with 'revins'", function() - local screen = Screen.new(30, 3) - screen:attach() + local _ = Screen.new(30, 3) command('setl ts=4 sw=4 revins') set_lines(0, 1, ('a'):rep(16), s(3) .. '\t' .. s(4) .. '\t a') feed('j$i') @@ -354,7 +345,6 @@ describe('insert-mode', function() it('backspace after replacing multibyte chars', function() local screen = Screen.new(30, 3) - screen:attach() api.nvim_buf_set_lines(0, 0, -1, true, { 'test ȧ̟̜̝̅̚m̆̉̐̐̇̈ å' }) feed('^Rabcdefghi') screen:expect([[ diff --git a/test/functional/editor/mode_normal_spec.lua b/test/functional/editor/mode_normal_spec.lua @@ -26,7 +26,6 @@ describe('Normal mode', function() it('&showcmd does not crash with :startinsert #28419', function() local screen = Screen.new(60, 17) - screen:attach() fn.termopen( { n.nvim_prog, '--clean', '--cmd', 'startinsert' }, { env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } } @@ -45,7 +44,6 @@ describe('Normal mode', function() it('replacing with ZWJ emoji sequences', function() local screen = Screen.new(30, 8) - screen:attach() api.nvim_buf_set_lines(0, 0, -1, true, { 'abcdefg' }) feed('05r🧑‍🌾') -- ZWJ screen:expect([[ diff --git a/test/functional/editor/put_spec.lua b/test/functional/editor/put_spec.lua @@ -883,7 +883,6 @@ describe('put command', function() local screen setup(function() screen = Screen.new() - screen:attach() end) local function bell_test(actions, should_ring) diff --git a/test/functional/editor/tabpage_spec.lua b/test/functional/editor/tabpage_spec.lua @@ -105,7 +105,6 @@ describe('tabpage', function() screen:add_extra_attr_ids { [100] = { bold = true, foreground = Screen.colors.Fuchsia }, } - screen:attach() command('tabnew') command('tabprev') diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua @@ -65,7 +65,6 @@ describe('the first line is redrawn correctly after inserting text in an empty b [1] = { bold = true, foreground = Screen.colors.Blue }, [2] = { bold = true, reverse = true }, }) - screen:attach() end) it('using :append', function() diff --git a/test/functional/ex_cmds/cmd_map_spec.lua b/test/functional/ex_cmds/cmd_map_spec.lua @@ -37,7 +37,6 @@ describe('mappings with <Cmd>', function() [9] = { background = Screen.colors.LightMagenta }, [10] = { foreground = Screen.colors.Red }, }) - screen:attach() cmdmap('<F3>', 'let m = mode(1)') cmdmap('<F4>', 'normal! ww') diff --git a/test/functional/ex_cmds/debug_spec.lua b/test/functional/ex_cmds/debug_spec.lua @@ -15,7 +15,6 @@ describe(':debug', function() [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, }) - screen:attach() end) it('scrolls messages correctly', function() feed(':echoerr bork<cr>') diff --git a/test/functional/ex_cmds/digraphs_spec.lua b/test/functional/ex_cmds/digraphs_spec.lua @@ -19,7 +19,6 @@ describe(':digraphs', function() [6] = { foreground = Screen.colors.Blue1 }, [7] = { bold = true, reverse = true }, }) - screen:attach() end) it('displays digraphs', function() diff --git a/test/functional/ex_cmds/drop_spec.lua b/test/functional/ex_cmds/drop_spec.lua @@ -11,7 +11,6 @@ describe(':drop', function() before_each(function() clear() screen = Screen.new(35, 10) - screen:attach() screen:set_default_attr_ids({ [0] = { bold = true, foreground = Screen.colors.Blue }, [1] = { bold = true, reverse = true }, diff --git a/test/functional/ex_cmds/highlight_spec.lua b/test/functional/ex_cmds/highlight_spec.lua @@ -10,12 +10,9 @@ local fn = n.fn local api = n.api describe(':highlight', function() - local screen - before_each(function() clear() - screen = Screen.new() - screen:attach() + local _ = Screen.new() end) it('invalid color name', function() diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua @@ -103,7 +103,6 @@ describe('Screen', function() before_each(function() clear() screen = Screen.new(20, 5) - screen:attach() end) it('cursor is restored after :map <expr> which calls input()', function() diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua @@ -201,8 +201,7 @@ describe(':mksession', function() local cwd_dir = fn.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '') local session_path = cwd_dir .. '/' .. session_file - screen = Screen.new(50, 6) - screen:attach({ rgb = false }) + screen = Screen.new(50, 6, { rgb = false }) local expected_screen = [[ ^/ | | @@ -222,8 +221,7 @@ describe(':mksession', function() -- Create a new test instance of Nvim. clear() - screen = Screen.new(50, 6) - screen:attach({ rgb = false }) + screen = Screen.new(50, 6, { rgb = false }) command('silent source ' .. session_path) -- Verify that the terminal's working directory is "/". diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua @@ -38,7 +38,6 @@ describe(':oldfiles', function() it('shows most recently used files', function() local screen = Screen.new(100, 5) - screen:attach() screen._default_attr_ids = nil feed_command('edit testfile1') feed_command('edit testfile2') diff --git a/test/functional/ex_cmds/quickfix_commands_spec.lua b/test/functional/ex_cmds/quickfix_commands_spec.lua @@ -199,7 +199,6 @@ describe('quickfix', function() it('jump message does not scroll with cmdheight=0 and shm+=O #29597', function() local screen = Screen.new(40, 6) - screen:attach() command('set cmdheight=0') local file = file_base .. '_reuse_qfbuf_BufAdd' write_file(file, 'foobar') @@ -226,7 +225,6 @@ it(':vimgrep can specify Unicode pattern without delimiters', function() [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText [1] = { reverse = true }, -- IncSearch }) - screen:attach() feed('i→<Esc>:vimgrep →') screen:expect([[ {1:→} | diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -114,7 +114,6 @@ describe("preserve and (R)ecover with custom 'directory'", function() it('killing TUI process without :preserve #22096', function() t.skip(t.is_os('win')) local screen0 = Screen.new() - screen0:attach() local child_server = new_pipename() fn.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--listen', child_server }, { env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }, @@ -171,7 +170,6 @@ describe('swapfile detection', function() local nvim2 = spawn({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed' }, true, nil, true) set_session(nvim2) local screen2 = Screen.new(256, 40) - screen2:attach() screen2._default_attr_ids = nil exec(init) command('autocmd! nvim_swapfile') -- Delete the default handler (which skips the dialog). @@ -254,7 +252,6 @@ describe('swapfile detection', function() local nvim1 = spawn(new_argv(), true, nil, true) set_session(nvim1) local screen = Screen.new(75, 18) - screen:attach() exec(init) feed(':edit Xfile1\n') @@ -325,7 +322,6 @@ describe('swapfile detection', function() [1] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg [2] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg }) - screen:attach() exec(init) if not swapexists then diff --git a/test/functional/example_spec.lua b/test/functional/example_spec.lua @@ -14,7 +14,6 @@ describe('example', function() before_each(function() clear() screen = Screen.new(20, 5) - screen:attach() screen:set_default_attr_ids({ [0] = { bold = true, foreground = Screen.colors.Blue }, [1] = { bold = true, foreground = Screen.colors.Brown }, @@ -47,8 +46,7 @@ describe('example', function() -- The UI must declare that it wants to handle the UI events. -- For this example, we enable `ext_tabline`: screen:detach() - screen = Screen.new(25, 5) - screen:attach({ rgb = true, ext_tabline = true }) + screen = Screen.new(25, 5, { rgb = true, ext_tabline = true }) -- From ":help ui" we find that `tabline_update` receives `curtab` and -- `tabs` objects. So we declare the UI handler like this: diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua @@ -11,7 +11,6 @@ describe('063: Test for ":match", "matchadd()" and related functions', function( it('is working', function() local screen = Screen.new(40, 5) - screen:attach() command('highlight MyGroup1 term=bold ctermbg=red guibg=red') command('highlight MyGroup2 term=italic ctermbg=green guibg=green') diff --git a/test/functional/legacy/107_adjust_window_and_contents_spec.lua b/test/functional/legacy/107_adjust_window_and_contents_spec.lua @@ -13,7 +13,6 @@ describe('107', function() it('is working', function() local screen = Screen.new() - screen:attach() insert('start:') poke_eventloop() diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua @@ -20,7 +20,6 @@ describe('argument list commands', function() it(':confirm quit with unedited files in arglist', function() local screen = Screen.new(60, 6) - screen:attach() command('set nomore') command('args a b c') feed(':confirm quit\n') diff --git a/test/functional/legacy/breakindent_spec.lua b/test/functional/legacy/breakindent_spec.lua @@ -17,7 +17,6 @@ describe('breakindent', function() [1] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue }, -- SignColumn [2] = { bold = true }, -- ModeMsg }) - screen:attach() exec([[ set listchars=eol:$ let &signcolumn = 'yes' @@ -68,7 +67,6 @@ describe('breakindent', function() setlocal breakindent call setline(1, "\t" .. join(range(100))) ]]) - screen:attach() feed('v$') screen:expect([[ diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua @@ -15,7 +15,6 @@ describe('cmdline', function() -- oldtest: Test_cmdlineclear_tabenter() it('is cleared when switching tabs', function() local screen = Screen.new(30, 10) - screen:attach() feed_command([[call setline(1, range(30))]]) screen:expect([[ @@ -79,7 +78,6 @@ describe('cmdline', function() -- oldtest: Test_verbose_option() it('prints every executed Ex command if verbose >= 16', function() local screen = Screen.new(60, 12) - screen:attach() exec([[ command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v call feedkeys("\r", 't') " for the hit-enter prompt @@ -104,7 +102,6 @@ describe('cmdline', function() -- oldtest: Test_cmdline_redraw_tabline() it('tabline is redrawn on entering cmdline', function() local screen = Screen.new(30, 6) - screen:attach() exec([[ set showtabline=2 autocmd CmdlineEnter * set tabline=foo @@ -121,7 +118,6 @@ describe('cmdline', function() -- oldtest: Test_redraw_in_autocmd() it('cmdline cursor position is correct after :redraw with cmdheight=2', function() local screen = Screen.new(30, 6) - screen:attach() exec([[ set cmdheight=2 autocmd CmdlineChanged * redraw @@ -145,7 +141,6 @@ describe('cmdline', function() it("setting 'cmdheight' works after outputting two messages vim-patch:9.0.0665", function() local screen = Screen.new(60, 8) - screen:attach() exec([[ set cmdheight=1 laststatus=2 func EchoTwo() @@ -175,7 +170,6 @@ describe('cmdline', function() -- oldtest: Test_cmdheight_tabline() it("changing 'cmdheight' when there is a tabline", function() local screen = Screen.new(60, 8) - screen:attach() api.nvim_set_option_value('laststatus', 2, {}) api.nvim_set_option_value('showtabline', 2, {}) api.nvim_set_option_value('cmdheight', 1, {}) @@ -191,7 +185,6 @@ describe('cmdline', function() -- oldtest: Test_rulerformat_position() it("ruler has correct position with 'rulerformat' set", function() local screen = Screen.new(20, 3) - screen:attach() api.nvim_set_option_value('ruler', true, {}) api.nvim_set_option_value('rulerformat', 'longish', {}) api.nvim_set_option_value('laststatus', 0, {}) @@ -218,7 +211,6 @@ describe('cmdwin', function() [3] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg [4] = { bold = true }, -- ModeMsg }) - screen:attach() command('set more') command('autocmd WinNew * highlight') feed('q:') diff --git a/test/functional/legacy/conceal_spec.lua b/test/functional/legacy/conceal_spec.lua @@ -21,7 +21,6 @@ describe('Conceal', function() -- oldtest: Test_conceal_two_windows() it('works', function() local screen = Screen.new(75, 12) - screen:attach() exec([[ let lines = ["one one one one one", "two |hidden| here", "three |hidden| three"] call setline(1, lines) @@ -385,7 +384,6 @@ describe('Conceal', function() screen:add_extra_attr_ids { [100] = { background = Screen.colors.LightRed }, } - screen:attach() -- Check that cursorcolumn and colorcolumn don't get broken in presence of -- wrapped lines containing concealed text -- luacheck: push ignore 613 (trailing whitespace in a string) @@ -434,7 +432,6 @@ describe('Conceal', function() screen:add_extra_attr_ids { [100] = { background = Screen.colors.WebGreen }, } - screen:attach() exec([[ call setline(1, 'one one one |hidden| one one one one one one one one') syntax match test /|hidden|/ conceal @@ -463,7 +460,6 @@ describe('Conceal', function() screen:add_extra_attr_ids { [100] = { background = Screen.colors.WebGreen }, } - screen:attach() exec([[ call setline(1, 'one one one |hidden| one one one one one one one one') syntax match test /|hidden|/ conceal @@ -489,7 +485,6 @@ describe('Conceal', function() -- oldtest: Test_conceal_resize_term() it('resize editor', function() local screen = Screen.new(75, 6) - screen:attach() exec([[ call setline(1, '`one` `two` `three` `four` `five`, the backticks should be concealed') setl cocu=n cole=3 @@ -513,7 +508,6 @@ describe('Conceal', function() -- oldtest: Test_conceal_linebreak() it('with linebreak', function() local screen = Screen.new(75, 8) - screen:attach() exec([[ let &wrap = v:true let &conceallevel = 2 @@ -619,7 +613,6 @@ describe('Conceal', function() local function test_conceal_virtualedit_after_eol(wrap) local screen = Screen.new(60, 3) - screen:attach() api.nvim_set_option_value('wrap', wrap, {}) exec([[ call setline(1, 'abcdefgh|hidden|ijklmnpop') @@ -670,7 +663,6 @@ describe('Conceal', function() local function test_conceal_virtualedit_after_eol_rightleft(wrap) local screen = Screen.new(60, 3) - screen:attach() api.nvim_set_option_value('wrap', wrap, {}) exec([[ call setline(1, 'abcdefgh|hidden|ijklmnpop') @@ -724,7 +716,6 @@ describe('Conceal', function() screen:add_extra_attr_ids { [100] = { background = Screen.colors.LightRed }, } - screen:attach() api.nvim_set_option_value('wrap', wrap, {}) exec([[ call setline(1, ['aaaaa口=口bbbbb口=口ccccc', 'foobar']) @@ -777,7 +768,6 @@ describe('Conceal', function() screen:add_extra_attr_ids { [100] = { background = Screen.colors.LightRed }, } - screen:attach() exec([[ call setline(1, 'aaaaaaaaaa口=口bbbbbbbbbb口=口cccccccccc') syntax match test /口=口/ conceal cchar=β diff --git a/test/functional/legacy/cpoptions_spec.lua b/test/functional/legacy/cpoptions_spec.lua @@ -10,7 +10,6 @@ before_each(clear) describe('cpoptions', function() it('$', function() local screen = Screen.new(30, 6) - screen:attach() command('set cpo+=$') command([[call setline(1, 'one two three')]]) feed('c2w') diff --git a/test/functional/legacy/debugger_spec.lua b/test/functional/legacy/debugger_spec.lua @@ -14,7 +14,6 @@ describe('debugger', function() before_each(function() screen = Screen.new(999, 10) - screen:attach() end) -- oldtest: Test_Debugger_breakadd_expr() diff --git a/test/functional/legacy/digraph_spec.lua b/test/functional/legacy/digraph_spec.lua @@ -10,7 +10,6 @@ describe('digraph', function() -- oldtest: Test_entering_digraph() it('characters displayed on the screen', function() local screen = Screen.new(10, 6) - screen:attach() feed('i<C-K>') screen:expect([[ {18:^?} | diff --git a/test/functional/legacy/display_spec.lua b/test/functional/legacy/display_spec.lua @@ -12,7 +12,6 @@ describe('display', function() -- oldtest: Test_display_scroll_at_topline() it('scroll when modified at topline vim-patch:8.2.1488', function() local screen = Screen.new(20, 4) - screen:attach() command([[call setline(1, repeat('a', 21))]]) feed('O') @@ -27,7 +26,6 @@ describe('display', function() -- oldtest: Test_display_scroll_update_visual() it('scrolling when modified at topline in Visual mode vim-patch:8.2.4626', function() local screen = Screen.new(60, 8) - screen:attach() exec([[ set scrolloff=0 @@ -52,7 +50,6 @@ describe('display', function() [2] = { bold = true, reverse = true }, -- StatusLine [3] = { reverse = true }, -- StatusLineNC }) - screen:attach() exec([[ call setline(1, ['aaa', 'b'->repeat(200)]) set display=truncate @@ -131,7 +128,6 @@ describe('display', function() -- oldtest: Test_display_long_lastline() it('"lastline" shows correct text when end of wrapped line is deleted', function() local screen = Screen.new(35, 14) - screen:attach() exec([[ set display=lastline smoothscroll scrolloff=0 call setline(1, [ @@ -183,7 +179,6 @@ describe('display', function() -- oldtest: Test_display_cursor_long_line() it("correctly shows line that doesn't fit in the window", function() local screen = Screen.new(75, 8) - screen:attach() exec([[ call setline(1, ['a', 'b ' .. 'bbbbb'->repeat(150), 'c']) norm $j diff --git a/test/functional/legacy/edit_spec.lua b/test/functional/legacy/edit_spec.lua @@ -31,7 +31,6 @@ describe('edit', function() -- oldtest: Test_edit_insert_reg() it('inserting a register using CTRL-R', function() local screen = Screen.new(10, 6) - screen:attach() feed('a<C-R>') screen:expect([[ {18:^"} | @@ -55,7 +54,6 @@ describe('edit', function() -- oldtest: Test_edit_ctrl_r_failed() it('positioning cursor after CTRL-R expression failed', function() local screen = Screen.new(60, 6) - screen:attach() feed('i<C-R>') screen:expect([[ diff --git a/test/functional/legacy/ex_mode_spec.lua b/test/functional/legacy/ex_mode_spec.lua @@ -47,7 +47,6 @@ describe('Ex mode', function() it('substitute confirmation prompt', function() command('set noincsearch nohlsearch inccommand=') local screen = Screen.new(60, 6) - screen:attach() command([[call setline(1, repeat(['foo foo'], 4))]]) command([[set number]]) feed('gQ') @@ -134,7 +133,6 @@ describe('Ex mode', function() it('pressing Ctrl-C in :append inside a loop in Ex mode does not hang', function() local screen = Screen.new(60, 6) - screen:attach() feed('gQ') feed('for i in range(1)<CR>') feed('append<CR>') diff --git a/test/functional/legacy/excmd_spec.lua b/test/functional/legacy/excmd_spec.lua @@ -19,7 +19,6 @@ describe(':confirm command dialog', function() local function start_new() clear() screen = Screen.new(75, 20) - screen:attach() end -- Test for the :confirm command dialog diff --git a/test/functional/legacy/fold_spec.lua b/test/functional/legacy/fold_spec.lua @@ -14,7 +14,6 @@ describe('folding', function() n.clear() screen = Screen.new(45, 8) - screen:attach() end) it('creation, opening, moving (to the end) and closing', function() diff --git a/test/functional/legacy/global_spec.lua b/test/functional/legacy/global_spec.lua @@ -12,7 +12,6 @@ describe(':global', function() -- oldtest: Test_interrupt_global() it('can be interrupted using Ctrl-C in cmdline mode vim-patch:9.0.0082', function() local screen = Screen.new(75, 6) - screen:attach() exec([[ set nohlsearch noincsearch diff --git a/test/functional/legacy/highlight_spec.lua b/test/functional/legacy/highlight_spec.lua @@ -15,7 +15,6 @@ before_each(clear) describe(':highlight', function() it('is working', function() local screen = Screen.new(35, 10) - screen:attach() -- Basic test if ":highlight" doesn't crash feed_command('set more') feed(':highlight<CR>') @@ -101,7 +100,6 @@ describe('Visual selection highlight', function() -- oldtest: Test_visual_sbr() it("when 'showbreak' is set", function() local screen = Screen.new(60, 6) - screen:attach() exec([[ set showbreak=> call setline(1, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.') diff --git a/test/functional/legacy/listchars_spec.lua b/test/functional/legacy/listchars_spec.lua @@ -103,7 +103,6 @@ describe("'listchars'", function() it('"exceeds" character does not appear in foldcolumn vim-patch:8.2.3121', function() local screen = Screen.new(60, 10) - screen:attach() exec([[ call setline(1, ['aaa', '', 'a', 'aaaaaa']) vsplit diff --git a/test/functional/legacy/listlbr_spec.lua b/test/functional/legacy/listlbr_spec.lua @@ -205,7 +205,6 @@ describe('listlbr', function() -- oldtest: Test_linebreak_reset_restore() it('cursor position is drawn correctly after operator', function() local screen = Screen.new(60, 6) - screen:attach() -- f_wincol() calls validate_cursor() source([[ diff --git a/test/functional/legacy/listlbr_utf8_spec.lua b/test/functional/legacy/listlbr_utf8_spec.lua @@ -215,7 +215,6 @@ describe('linebreak', function() -- oldtest: Test_visual_ends_before_showbreak() it("Visual area is correct when it ends before multibyte 'showbreak'", function() local screen = Screen.new(60, 8) - screen:attach() exec([[ let &wrap = v:true let &linebreak = v:true diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua @@ -196,7 +196,6 @@ describe('mapping', function() -- oldtest: Test_showcmd_part_map() it("'showcmd' with a partial mapping", function() local screen = Screen.new(60, 6) - screen:attach() exec([[ set notimeout showcmd nnoremap ,a <Ignore> diff --git a/test/functional/legacy/match_spec.lua b/test/functional/legacy/match_spec.lua @@ -11,7 +11,6 @@ describe('matchaddpos()', function() -- oldtest: Test_matchaddpos_dump() it('can add more than 8 match positions vim-patch:9.0.0620', function() local screen = Screen.new(60, 14) - screen:attach() exec([[ call setline(1, ['1234567890123']->repeat(14)) call matchaddpos('Search', range(1, 12)->map({i, v -> [v, v]})) @@ -39,7 +38,6 @@ describe('match highlighting', function() -- oldtest: Test_match_in_linebreak() it('does not continue in linebreak vim-patch:8.2.3698', function() local screen = Screen.new(75, 10) - screen:attach() exec([=[ set breakindent linebreak breakat+=] call printf('%s]%s', repeat('x', 50), repeat('x', 70))->setline(1) @@ -55,7 +53,6 @@ describe('match highlighting', function() it('is shown with incsearch vim-patch:8.2.3940', function() local screen = Screen.new(75, 6) - screen:attach() exec([[ set incsearch call setline(1, range(20)) @@ -82,7 +79,6 @@ describe('match highlighting', function() it('on a Tab vim-patch:8.2.4062', function() local screen = Screen.new(75, 10) - screen:attach() exec([[ set linebreak call setline(1, "\tix") diff --git a/test/functional/legacy/matchparen_spec.lua b/test/functional/legacy/matchparen_spec.lua @@ -11,7 +11,6 @@ describe('matchparen', function() -- oldtest: Test_visual_block_scroll() it('redraws properly after scrolling with scrolloff=1', function() local screen = Screen.new(30, 7) - screen:attach() exec([[ source $VIMRUNTIME/plugin/matchparen.vim set scrolloff=1 @@ -37,7 +36,6 @@ describe('matchparen', function() screen:add_extra_attr_ids { [100] = { background = Screen.colors.Cyan1 }, } - screen:attach() local screen1 = [[ {100:^()} | @@ -79,7 +77,6 @@ describe('matchparen', function() screen:add_extra_attr_ids { [100] = { background = Screen.colors.Cyan1 }, } - screen:attach() exec([[ source $VIMRUNTIME/plugin/matchparen.vim @@ -107,7 +104,6 @@ describe('matchparen', function() -- oldtest: Test_matchparen_pum_clear() it('is cleared when completion popup is shown', function() local screen = Screen.new(30, 9) - screen:attach() exec([[ source $VIMRUNTIME/plugin/matchparen.vim @@ -136,7 +132,6 @@ describe('matchparen', function() screen:add_extra_attr_ids { [100] = { background = Screen.colors.Cyan1 }, } - screen:attach() exec([[ source $VIMRUNTIME/plugin/matchparen.vim diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua @@ -17,7 +17,6 @@ describe('messages', function() -- oldtest: Test_warning_scroll() it('a warning causes scrolling if and only if it has a stacktrace', function() screen = Screen.new(75, 6) - screen:attach() -- When the warning comes from a script, messages are scrolled so that the -- stacktrace is visible. @@ -45,7 +44,6 @@ describe('messages', function() -- oldtest: Test_message_not_cleared_after_mode() it('clearing mode does not remove message', function() screen = Screen.new(60, 10) - screen:attach() exec([[ nmap <silent> gx :call DebugSilent('normal')<CR> vmap <silent> gx :call DebugSilent('visual')<CR> @@ -101,7 +99,6 @@ describe('messages', function() [1] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg [2] = { foreground = Screen.colors.Brown }, -- LineNr }) - screen:attach() command('call setline(1, range(1, 100))') @@ -394,7 +391,6 @@ describe('messages', function() -- oldtest: Test_echo_verbose_system() it('verbose message before echo command', function() screen = Screen.new(60, 10) - screen:attach() command('cd ' .. nvim_dir) api.nvim_set_option_value('shell', './shell-test', {}) @@ -494,7 +490,6 @@ describe('messages', function() -- oldtest: Test_quit_long_message() it('with control characters can be quit vim-patch:8.2.1844', function() screen = Screen.new(40, 10) - screen:attach() feed([[:echom range(9999)->join("\x01")<CR>]]) screen:expect([[ @@ -521,7 +516,6 @@ describe('messages', function() describe('mode is cleared when', function() before_each(function() screen = Screen.new(40, 6) - screen:attach() end) -- oldtest: Test_mode_message_at_leaving_insert_by_ctrl_c() @@ -591,7 +585,6 @@ describe('messages', function() -- oldtest: Test_ask_yesno() it('y/n prompt works', function() screen = Screen.new(75, 6) - screen:attach() command('set noincsearch nohlsearch inccommand=') command('call setline(1, range(1, 2))') @@ -644,7 +637,6 @@ describe('messages', function() -- oldtest: Test_fileinfo_tabpage_cmdheight() it("fileinfo works when 'cmdheight' has just decreased", function() screen = Screen.new(40, 6) - screen:attach() exec([[ set shortmess-=o @@ -673,7 +665,6 @@ describe('messages', function() -- oldtest: Test_fileinfo_after_echo() it('fileinfo does not overwrite echo message vim-patch:8.2.4156', function() screen = Screen.new(40, 6) - screen:attach() exec([[ set shortmess-=F diff --git a/test/functional/legacy/move_spec.lua b/test/functional/legacy/move_spec.lua @@ -11,7 +11,6 @@ describe(':move', function() -- oldtest: Test_move_undo() it('redraws correctly when undone', function() local screen = Screen.new(60, 10) - screen:attach() fn.setline(1, { 'First', 'Second', 'Third', 'Fourth' }) feed('gg:move +1<CR>') diff --git a/test/functional/legacy/normal_spec.lua b/test/functional/legacy/normal_spec.lua @@ -15,7 +15,6 @@ describe('normal', function() before_each(function() clear() screen = Screen.new(40, 19) - screen:attach() end) -- oldtest: Test_normal_j_below_botline() diff --git a/test/functional/legacy/number_spec.lua b/test/functional/legacy/number_spec.lua @@ -17,7 +17,6 @@ describe("'number' and 'relativenumber'", function() [2] = { foreground = Screen.colors.Blue }, [3] = { foreground = Screen.colors.Green }, }) - screen:attach() exec([[ call setline(1, range(200)) 111 @@ -86,7 +85,6 @@ describe("'number' and 'relativenumber'", function() [3] = { background = Screen.colors.Green, foreground = Screen.colors.Black }, [4] = { bold = true, foreground = Screen.colors.Blue }, }) - screen:attach() exec([[ set display=lastline scrolloff=0 call setline(1, range(200)->map('v:val->string()->repeat(40)')) @@ -215,7 +213,6 @@ describe("'number' and 'relativenumber'", function() -- oldtest: Test_relativenumber_callback() it('relative line numbers are updated if cursor is moved from timer', function() local screen = Screen.new(50, 8) - screen:attach() exec([[ call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd']) set relativenumber @@ -253,7 +250,6 @@ describe("'number' and 'relativenumber'", function() -- oldtest: Test_number_insert_delete_lines() it('line numbers are updated when deleting/inserting lines', function() local screen = Screen.new(50, 8) - screen:attach() exec([[ call setline(1, range(1, 7)) set number diff --git a/test/functional/legacy/options_spec.lua b/test/functional/legacy/options_spec.lua @@ -32,8 +32,7 @@ describe('set', function() end) it('winminheight works', function() - local screen = Screen.new(20, 11) - screen:attach() + local _ = Screen.new(20, 11) source([[ set wmh=0 stal=2 below sp | wincmd _ @@ -45,8 +44,7 @@ describe('set', function() end) it('winminheight works with tabline', function() - local screen = Screen.new(20, 11) - screen:attach() + local _ = Screen.new(20, 11) source([[ set wmh=0 stal=2 split @@ -60,7 +58,6 @@ describe('set', function() it('scroll works', function() local screen = Screen.new(42, 16) - screen:attach() source([[ set scroll=2 set laststatus=2 diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua @@ -18,7 +18,6 @@ describe('prompt buffer', function() before_each(function() clear() screen = Screen.new(25, 10) - screen:attach() command('set laststatus=0 nohidden') end) @@ -68,10 +67,6 @@ describe('prompt buffer', function() ]]) end - after_each(function() - screen:detach() - end) - -- oldtest: Test_prompt_basic() it('works', function() source_script() diff --git a/test/functional/legacy/put_spec.lua b/test/functional/legacy/put_spec.lua @@ -10,7 +10,6 @@ describe('put', function() -- oldtest: Test_put_other_window() it('above topline in buffer in two splits', function() local screen = Screen.new(80, 10) - screen:attach() source([[ 40vsplit 0put ='some text at the top' @@ -36,7 +35,6 @@ describe('put', function() -- oldtest: Test_put_in_last_displayed_line() it('in last displayed line', function() local screen = Screen.new(75, 10) - screen:attach() source([[ autocmd CursorMoved * eval line('w$') let @a = 'x'->repeat(&columns * 2 - 2) diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua @@ -13,7 +13,6 @@ describe('smoothscroll', function() before_each(function() screen = Screen.new(40, 12) - screen:attach() end) -- oldtest: Test_CtrlE_CtrlY_stop_at_end() diff --git a/test/functional/legacy/search_spec.lua b/test/functional/legacy/search_spec.lua @@ -18,7 +18,6 @@ describe('search cmdline', function() clear() command('set nohlsearch inccommand=') screen = Screen.new(20, 3) - screen:attach() screen:set_default_attr_ids({ inc = { reverse = true }, err = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, @@ -747,7 +746,6 @@ describe('Search highlight', function() -- oldtest: Test_hlsearch_dump() it('beyond line end vim-patch:8.2.2542', function() local screen = Screen.new(50, 6) - screen:attach() exec([[ set hlsearch noincsearch cursorline call setline(1, ["xxx", "xxx", "xxx"]) @@ -773,7 +771,6 @@ describe('Search highlight', function() [4] = { background = Screen.colors.Yellow, bold = true }, -- Search [5] = { background = Screen.colors.LightGrey, bold = true, foreground = Screen.colors.Black }, }) - screen:attach() exec([[ set hlsearch noincsearch call setline(1, repeat(["xxx yyy zzz"], 3)) diff --git a/test/functional/legacy/search_stat_spec.lua b/test/functional/legacy/search_stat_spec.lua @@ -15,7 +15,6 @@ describe('search stat', function() [4] = { reverse = true }, -- IncSearch, TabLineFill [5] = { foreground = Screen.colors.Red }, -- WarningMsg }) - screen:attach() end) -- oldtest: Test_search_stat_screendump() diff --git a/test/functional/legacy/signs_spec.lua b/test/functional/legacy/signs_spec.lua @@ -26,7 +26,6 @@ describe('signs', function() -- oldtest: Test_sign_cursor_position() it('are drawn correctly', function() local screen = Screen.new(75, 6) - screen:attach() exec([[ call setline(1, [repeat('x', 75), 'mmmm', 'yyyy']) call cursor(2,1) diff --git a/test/functional/legacy/source_spec.lua b/test/functional/legacy/source_spec.lua @@ -18,7 +18,6 @@ describe(':source!', function() ]] ) local screen = Screen.new(75, 6) - screen:attach() feed(':source! Xscript.vim\n') screen:expect([[ ^ | diff --git a/test/functional/legacy/statusline_spec.lua b/test/functional/legacy/statusline_spec.lua @@ -12,7 +12,6 @@ describe('statusline', function() before_each(function() screen = Screen.new(50, 7) - screen:attach() end) it('is updated in cmdline mode when using window-local statusline vim-patch:8.2.2737', function() diff --git a/test/functional/legacy/substitute_spec.lua b/test/functional/legacy/substitute_spec.lua @@ -211,7 +211,6 @@ describe(':substitute', function() it('first char is highlighted with confirmation dialog and empty match', function() local screen = Screen.new(60, 8) - screen:attach() exec([[ set nohlsearch noincsearch call setline(1, ['one', 'two', 'three']) diff --git a/test/functional/legacy/tabline_spec.lua b/test/functional/legacy/tabline_spec.lua @@ -12,7 +12,6 @@ describe('tabline', function() before_each(function() screen = Screen.new(50, 7) - screen:attach() end) -- oldtest: Test_tabline_showcmd() diff --git a/test/functional/legacy/vimscript_spec.lua b/test/functional/legacy/vimscript_spec.lua @@ -12,7 +12,6 @@ describe('Vim script', function() -- oldtest: Test_deep_nest() it('Error when if/for/while/try/function is nested too deep', function() local screen = Screen.new(80, 24) - screen:attach() api.nvim_set_option_value('laststatus', 2, {}) exec([[ " Deep nesting of if ... endif @@ -84,7 +83,6 @@ describe('Vim script', function() -- oldtest: Test_typed_script_var() it('using s: with a typed command', function() local screen = Screen.new(80, 24) - screen:attach() feed(":echo get(s:, 'foo', 'x')\n") screen:expect({ any = 'E116: ' }) end) diff --git a/test/functional/legacy/visual_spec.lua b/test/functional/legacy/visual_spec.lua @@ -12,7 +12,6 @@ describe('Visual highlight', function() before_each(function() screen = Screen.new(50, 6) - screen:attach() end) -- oldtest: Test_visual_block_with_virtualedit() diff --git a/test/functional/legacy/window_cmd_spec.lua b/test/functional/legacy/window_cmd_spec.lua @@ -11,7 +11,6 @@ local feed = n.feed it('scrolling with laststatus=0 and :botright split', function() clear('--cmd', 'set ruler') local screen = Screen.new(40, 10) - screen:attach() exec([[ set laststatus=0 call setline(1, range(1, 100)) @@ -38,7 +37,6 @@ describe('splitkeep', function() before_each(function() clear('--cmd', 'set splitkeep=screen') screen = Screen.new() - screen:attach() end) -- oldtest: Test_splitkeep_cursor() diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua @@ -344,7 +344,6 @@ describe('lua buffer event callbacks: on_lines', function() it('setting extmark in on_lines callback works', function() local screen = Screen.new(40, 6) - screen:attach() api.nvim_buf_set_lines(0, 0, -1, true, { 'aaa', 'bbb', 'ccc' }) exec_lua(function() diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua @@ -111,7 +111,6 @@ describe(':lua', function() it('can show multiline error messages', function() local screen = Screen.new(40, 10) - screen:attach() screen:set_default_attr_ids({ [1] = { bold = true, foreground = Screen.colors.Blue1 }, [2] = { bold = true, reverse = true }, @@ -204,7 +203,6 @@ describe(':lua', function() it('with range', function() local screen = Screen.new(40, 10) - screen:attach() api.nvim_buf_set_lines(0, 0, 0, 0, { 'nonsense', 'function x() print "hello" end', 'x()' }) -- ":{range}lua" fails on invalid Lua code. diff --git a/test/functional/lua/hl_spec.lua b/test/functional/lua/hl_spec.lua @@ -18,7 +18,6 @@ describe('vim.hl.range', function() screen:add_extra_attr_ids({ [100] = { foreground = Screen.colors.Blue, background = Screen.colors.Yellow, bold = true }, }) - screen:attach() api.nvim_set_option_value('list', true, {}) api.nvim_set_option_value('listchars', 'eol:$', {}) api.nvim_buf_set_lines(0, 0, -1, true, { diff --git a/test/functional/lua/loop_spec.lua b/test/functional/lua/loop_spec.lua @@ -65,7 +65,6 @@ describe('vim.uv', function() it('is API safe', function() local screen = Screen.new(50, 10) - screen:attach() screen:set_default_attr_ids({ [1] = { bold = true, foreground = Screen.colors.Blue1 }, [2] = { bold = true, reverse = true }, diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua @@ -510,7 +510,6 @@ describe('v:lua', function() it('works in func options', function() local screen = Screen.new(60, 8) - screen:attach() api.nvim_set_option_value('omnifunc', 'v:lua.mymod.omni', {}) feed('isome st<c-x><c-o>') screen:expect{grid=[[ diff --git a/test/functional/lua/overrides_spec.lua b/test/functional/lua/overrides_spec.lua @@ -158,7 +158,6 @@ describe('print', function() it('blank line in message works', function() local screen = Screen.new(40, 8) - screen:attach() screen:set_default_attr_ids({ [0] = { bold = true, foreground = Screen.colors.Blue }, [1] = { bold = true, foreground = Screen.colors.SeaGreen }, @@ -196,7 +195,6 @@ describe('debug.debug', function() before_each(function() screen = Screen.new() - screen:attach() screen:set_default_attr_ids { [0] = { bold = true, foreground = 255 }, [1] = { bold = true, reverse = true }, diff --git a/test/functional/lua/secure_spec.lua b/test/functional/lua/secure_spec.lua @@ -39,7 +39,6 @@ describe('vim.secure', function() it('works', function() local screen = Screen.new(80, 8) - screen:attach() screen:set_default_attr_ids({ [1] = { bold = true, foreground = Screen.colors.Blue1 }, [2] = { bold = true, reverse = true }, diff --git a/test/functional/lua/thread_spec.lua b/test/functional/lua/thread_spec.lua @@ -17,7 +17,6 @@ describe('thread', function() before_each(function() clear() screen = Screen.new(50, 10) - screen:attach() end) it('entry func is executed in protected mode', function() @@ -257,7 +256,6 @@ describe('threadpool', function() it('with invalid return value', function() local screen = Screen.new(50, 10) - screen:attach() exec_lua [[ local work = vim.uv.new_work(function() return {} end, function() end) diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua @@ -41,7 +41,6 @@ describe('vim.ui_attach', function() [6] = { reverse = true, bold = true }, [7] = { background = Screen.colors.Yellow1 }, }) - screen:attach() end) local function expect_events(expected) @@ -251,8 +250,7 @@ describe('vim.ui_attach', function() it('error in callback is logged', function() clear({ env = { NVIM_LOG_FILE = testlog } }) - local screen = Screen.new() - screen:attach() + local _ = Screen.new() exec_lua([[ local ns = vim.api.nvim_create_namespace('testspace') vim.ui_attach(ns, { ext_popupmenu = true }, function() error(42) end) diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua @@ -637,7 +637,6 @@ describe('lua stdlib', function() matches('big failure\nvery async', remove_trace(eval('v:errmsg'))) local screen = Screen.new(60, 5) - screen:attach() screen:expect { grid = [[ ^ | @@ -1403,7 +1402,6 @@ describe('lua stdlib', function() end) local screen = Screen.new(50, 7) - screen:attach() exec_lua([[ timer = vim.uv.new_timer() timer:start(20, 0, function () @@ -2130,7 +2128,6 @@ describe('lua stdlib', function() eq({ 1, 5 }, api.nvim_win_get_cursor(0)) local screen = Screen.new(60, 3) - screen:attach() eq(1, eval('v:hlsearch')) screen:expect { grid = [[ @@ -3401,7 +3398,6 @@ stack traceback: it('callback is not invoked recursively #30752', function() local screen = Screen.new(60, 10) - screen:attach() exec_lua([[ vim.on_key(function(key, typed) vim.api.nvim_echo({ @@ -3779,7 +3775,6 @@ stack traceback: it('fails in fast callbacks #26122', function() local screen = Screen.new(80, 10) - screen:attach() exec_lua([[ local timer = vim.uv.new_timer() timer:start(0, 0, function() @@ -3797,7 +3792,6 @@ stack traceback: it('vim.notify_once', function() local screen = Screen.new(60, 5) - screen:attach() screen:expect { grid = [[ ^ | @@ -3994,7 +3988,6 @@ stack traceback: it('updates ruler if cursor moved', function() -- Fixed for win_execute in vim-patch:8.1.2124, but should've applied to nvim_win_call too! local screen = Screen.new(30, 5) - screen:attach() exec_lua [[ _G.api = vim.api vim.opt.ruler = true @@ -4137,7 +4130,6 @@ stack traceback: it('vim.lua_omnifunc', function() local screen = Screen.new(60, 5) - screen:attach() command [[ set omnifunc=v:lua.vim.lua_omnifunc ]] -- Note: the implementation is shared with lua command line completion. diff --git a/test/functional/lua/with_spec.lua b/test/functional/lua/with_spec.lua @@ -1029,7 +1029,6 @@ describe('vim._with', function() [1] = { bold = true, reverse = true }, [2] = { bold = true, foreground = Screen.colors.Blue }, } - screen:attach() exec_lua [[ vim._with({ silent = true }, function() vim.cmd.echo('"ccc"') end) ]] screen:expect [[ ^ | @@ -1178,7 +1177,6 @@ describe('vim._with', function() [1] = { reverse = true }, [2] = { bold = true, reverse = true }, } - screen:attach() exec_lua [[ vim.opt.ruler = true local lines = {} diff --git a/test/functional/options/belloff_spec.lua b/test/functional/options/belloff_spec.lua @@ -16,7 +16,6 @@ describe("'belloff'", function() before_each(function() clear() screen = Screen.new(42, 5) - screen:attach() screen:expect([[ ^ | {1:~ }|*3 diff --git a/test/functional/options/chars_spec.lua b/test/functional/options/chars_spec.lua @@ -16,7 +16,6 @@ describe("'fillchars'", function() before_each(function() clear() screen = Screen.new(25, 5) - screen:attach() end) describe('"eob" flag', function() @@ -157,7 +156,6 @@ describe("'listchars'", function() before_each(function() clear() screen = Screen.new(50, 5) - screen:attach() end) it('has global value', function() diff --git a/test/functional/options/cursorbind_spec.lua b/test/functional/options/cursorbind_spec.lua @@ -18,7 +18,6 @@ describe("'cursorbind'", function() [3] = { reverse = true }, -- StatusLineNC [4] = { background = Screen.colors.Grey90 }, -- CursorLine, CursorColumn }) - screen:attach() exec([[ call setline(1, 'aa bb cc dd ee ff gg hh ii jj kk ll mm' .. \ ' nn oo pp qq rr ss tt uu vv ww xx yy zz') diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua @@ -34,7 +34,6 @@ describe('startup defaults', function() describe(':filetype', function() local function expect_filetype(expected) local screen = Screen.new(50, 4) - screen:attach() command('filetype') screen:expect([[ ^ | @@ -127,7 +126,6 @@ describe('startup defaults', function() it('vert/fold flags', function() clear() local screen = Screen.new(50, 5) - screen:attach() command('set laststatus=0') insert([[ 1 diff --git a/test/functional/options/shortmess_spec.lua b/test/functional/options/shortmess_spec.lua @@ -14,7 +14,6 @@ describe("'shortmess'", function() before_each(function() clear() screen = Screen.new(42, 5) - screen:attach() end) describe('"F" flag', function() diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua @@ -155,7 +155,6 @@ describe('vim.health', function() it('highlights OK, ERROR', function() local screen = Screen.new(50, 12) - screen:attach() screen:set_default_attr_ids({ h1 = { reverse = true }, h2 = { foreground = tonumber('0x6a0dad') }, @@ -222,7 +221,7 @@ describe(':checkhealth window', function() end) it('opens directly if no buffer created', function() - local screen = Screen.new(50, 12) + local screen = Screen.new(50, 12, { ext_multigrid = true }) screen:set_default_attr_ids { h1 = { reverse = true }, h2 = { foreground = tonumber('0x6a0dad') }, @@ -230,7 +229,6 @@ describe(':checkhealth window', function() [14] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }, [32] = { foreground = Screen.colors.PaleGreen2 }, } - screen:attach({ ext_multigrid = true }) command('checkhealth success1') screen:expect { grid = [[ @@ -256,7 +254,7 @@ describe(':checkhealth window', function() end) local function test_health_vsplit(left, emptybuf, mods) - local screen = Screen.new(50, 20) + local screen = Screen.new(50, 20, { ext_multigrid = true }) screen:set_default_attr_ids { h1 = { reverse = true }, h2 = { foreground = tonumber('0x6a0dad') }, @@ -264,7 +262,6 @@ describe(':checkhealth window', function() [14] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }, [32] = { foreground = Screen.colors.PaleGreen2 }, } - screen:attach({ ext_multigrid = true }) if not emptybuf then insert('hello') end @@ -322,8 +319,7 @@ describe(':checkhealth window', function() end local function test_health_split(top, emptybuf, mods) - local screen = Screen.new(50, 25) - screen:attach({ ext_multigrid = true }) + local screen = Screen.new(50, 25, { ext_multigrid = true }) screen._default_attr_ids = nil if not emptybuf then insert('hello') diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua @@ -67,7 +67,6 @@ int main() { before_each(function() clear_notrace() screen = Screen.new(50, 9) - screen:attach() bufnr = n.api.nvim_get_current_buf() exec_lua(create_server_definition) @@ -339,7 +338,6 @@ test text before_each(function() clear_notrace() screen = Screen.new(50, 3) - screen:attach() exec_lua(create_server_definition) bufnr = n.api.nvim_get_current_buf() diff --git a/test/functional/plugin/lsp/semantic_tokens_spec.lua b/test/functional/plugin/lsp/semantic_tokens_spec.lua @@ -28,7 +28,6 @@ describe('semantic token highlighting', function() local screen --- @type test.functional.ui.screen before_each(function() screen = Screen.new(40, 16) - screen:attach() screen:set_default_attr_ids { [1] = { bold = true, foreground = Screen.colors.Blue1 }, [2] = { foreground = Screen.colors.DarkCyan }, diff --git a/test/functional/plugin/lsp/utils_spec.lua b/test/functional/plugin/lsp/utils_spec.lua @@ -181,11 +181,9 @@ describe('vim.lsp.util', function() eq(expected_anchor, string.sub(opts.anchor, 1, 1)) end - local screen --- @type test.functional.ui.screen before_each(function() n.clear() - screen = Screen.new(80, 80) - screen:attach() + local _ = Screen.new(80, 80) feed('79i<CR><Esc>') -- fill screen with empty lines end) diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua @@ -60,7 +60,6 @@ describe(':Man', function() c = { foreground = Screen.colors.Blue }, -- control chars eob = { bold = true, foreground = Screen.colors.Blue }, -- empty line '~'s }) - screen:attach() end) it('clears backspaces from text and adds highlights', function() diff --git a/test/functional/plugin/matchparen_spec.lua b/test/functional/plugin/matchparen_spec.lua @@ -14,7 +14,6 @@ describe('matchparen', function() before_each(function() clear { args = { '-u', 'NORC' } } screen = Screen.new(20, 5) - screen:attach() screen:set_default_attr_ids({ [0] = { bold = true, foreground = 255 }, [1] = { bold = true }, diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua @@ -3053,7 +3053,6 @@ describe('syntax/shada.vim', function() [7] = { bold = true, reverse = true }, [8] = { bold = true, foreground = Screen.colors.Blue }, } - screen:attach() api.nvim_buf_set_lines(0, 0, 1, true, { 'Header with timestamp ' .. epoch .. ':', diff --git a/test/functional/plugin/tohtml_spec.lua b/test/functional/plugin/tohtml_spec.lua @@ -185,8 +185,7 @@ describe(':TOhtml', function() local screen before_each(function() clear({ args = { '--clean' } }) - screen = Screen.new(80, 80) - screen:attach({ term_name = 'xterm' }) + screen = Screen.new(80, 80, { term_name = 'xterm' }) exec('colorscheme default') end) diff --git a/test/functional/plugin/tutor_spec.lua b/test/functional/plugin/tutor_spec.lua @@ -24,7 +24,6 @@ describe(':Tutor', function() [5] = { bold = true, foreground = Screen.colors.Magenta1 }, [6] = { italic = true }, }) - screen:attach() end) it('applies {unix:…,win:…} transform', function() diff --git a/test/functional/plugin/vim_syntax_spec.lua b/test/functional/plugin/vim_syntax_spec.lua @@ -21,7 +21,6 @@ describe('Vimscript syntax highlighting', function() [1] = { foreground = Screen.colors.Brown, bold = true }, [2] = { foreground = tonumber('0x6a0dad') }, }) - screen:attach() end) it('prefixed boolean options are highlighted properly', function() diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua @@ -94,7 +94,6 @@ describe('clipboard', function() before_each(function() clear() screen = Screen.new(72, 4) - screen:attach() end) it('unnamed register works without provider', function() @@ -318,7 +317,6 @@ describe('clipboard (with fake clipboard.vim)', function() it('`:redir @+>|bogus_cmd|redir END` must not recurse #7184', function() local screen = Screen.new(72, 4) - screen:attach() feed_command('redir @+> | bogus_cmd | redir END') screen:expect([[ ^ | @@ -641,7 +639,6 @@ describe('clipboard (with fake clipboard.vim)', function() it('supports "+ and "* in registers', function() local screen = Screen.new(60, 10) - screen:attach() feed_command("let g:test_clip['*'] = ['some', 'star data','']") feed_command("let g:test_clip['+'] = ['such', 'plus', 'stuff']") feed_command('registers') @@ -709,7 +706,6 @@ describe('clipboard (with fake clipboard.vim)', function() feed_command('set mouse=a') local screen = Screen.new(30, 5) - screen:attach() insert([[ the source a target]]) diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua @@ -411,7 +411,6 @@ describe(':terminal buffer', function() it('handles split UTF-8 sequences #16245', function() local screen = Screen.new(50, 7) - screen:attach() fn.termopen({ testprg('shell-test'), 'UTF-8' }) screen:expect([[ ^å | @@ -425,7 +424,6 @@ describe(':terminal buffer', function() it("handles bell respecting 'belloff' and 'visualbell'", function() local screen = Screen.new(50, 7) - screen:attach() local chan = api.nvim_open_term(0, {}) command('set belloff=') @@ -700,7 +698,6 @@ describe('termopen()', function() local function test_term_colorterm(expected, opts) local screen = Screen.new(50, 4) - screen:attach() fn.termopen({ nvim_prog, '-u', diff --git a/test/functional/terminal/channel_spec.lua b/test/functional/terminal/channel_spec.lua @@ -21,7 +21,6 @@ describe('terminal channel is closed and later released if', function() before_each(function() clear() screen = Screen.new() - screen:attach() end) it('opened by nvim_open_term() and deleted by :bdelete!', function() @@ -122,7 +121,6 @@ end) it('chansend sends lines to terminal channel in proper order', function() clear({ args = { '--cmd', 'set laststatus=2' } }) local screen = Screen.new(100, 20) - screen:attach() screen._default_attr_ids = nil local shells = is_os('win') and { 'cmd.exe', 'pwsh.exe -nop', 'powershell.exe -nop' } or { 'sh' } for _, sh in ipairs(shells) do @@ -149,7 +147,6 @@ describe('no crash when TermOpen autocommand', function() screen:set_default_attr_ids({ [0] = { bold = true, foreground = Screen.colors.Blue }, }) - screen:attach() end) it('processes job exit event when using termopen()', function() @@ -231,7 +228,6 @@ describe('nvim_open_term', function() before_each(function() clear() screen = Screen.new(8, 10) - screen:attach() end) it('with force_crlf=true converts newlines', function() diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua @@ -122,13 +122,12 @@ describe('cursor with customized highlighting', function() clear() command('highlight TermCursor ctermfg=45 ctermbg=46 cterm=NONE') command('highlight TermCursorNC ctermfg=55 ctermbg=56 cterm=NONE') - screen = Screen.new(50, 7) + screen = Screen.new(50, 7, { rgb = false }) screen:set_default_attr_ids({ [1] = { foreground = 45, background = 46 }, [2] = { foreground = 55, background = 56 }, [3] = { bold = true }, }) - screen:attach({ rgb = false }) command('call termopen(["' .. testprg('tty-test') .. '"])') feed('i') poke_eventloop() diff --git a/test/functional/terminal/edit_spec.lua b/test/functional/terminal/edit_spec.lua @@ -1,7 +1,7 @@ local t = require('test.testutil') local n = require('test.functional.testnvim')() -local screen = require('test.functional.ui.screen') +local Screen = require('test.functional.ui.screen') local testprg = n.testprg local command = n.command @@ -13,12 +13,6 @@ local matches = t.matches local pesc = vim.pesc describe(':edit term://*', function() - local get_screen = function(columns, lines) - local scr = screen.new(columns, lines) - scr:attach({ rgb = false }) - return scr - end - before_each(function() clear() api.nvim_set_option_value('shell', testprg('shell-test'), {}) @@ -37,7 +31,7 @@ describe(':edit term://*', function() it("runs TermOpen early enough to set buffer-local 'scrollback'", function() local columns, lines = 20, 4 - local scr = get_screen(columns, lines) + local scr = Screen.new(columns, lines, { rgb = false }) local rep = 97 api.nvim_set_option_value('shellcmdflag', 'REP ' .. rep, {}) command('set shellxquote=') -- win: avoid extra quotes diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua @@ -21,8 +21,7 @@ describe(':terminal', function() before_each(function() clear() - screen = Screen.new(50, 4) - screen:attach({ rgb = false }) + screen = Screen.new(50, 4, { rgb = false }) screen._default_attr_ids = nil end) @@ -169,8 +168,7 @@ local function test_terminal_with_fake_shell(backslash) before_each(function() clear() - screen = Screen.new(50, 4) - screen:attach({ rgb = false }) + screen = Screen.new(50, 4, { rgb = false }) screen._default_attr_ids = nil api.nvim_set_option_value('shell', shell_path, {}) api.nvim_set_option_value('shellcmdflag', 'EXE', {}) diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua @@ -17,7 +17,7 @@ describe(':terminal highlight', function() before_each(function() clear() - screen = Screen.new(50, 7) + screen = Screen.new(50, 7, { rgb = false }) screen:set_default_attr_ids({ [1] = { foreground = 45 }, [2] = { background = 46 }, @@ -33,7 +33,6 @@ describe(':terminal highlight', function() [12] = { bold = true, underdouble = true }, [13] = { italic = true, undercurl = true }, }) - screen:attach({ rgb = false }) command(("enew | call termopen(['%s'])"):format(testprg('tty-test'))) feed('i') screen:expect([[ @@ -130,7 +129,7 @@ end) it(':terminal highlight has lower precedence than editor #9964', function() clear() - local screen = Screen.new(30, 4) + local screen = Screen.new(30, 4, { rgb = true }) screen:set_default_attr_ids({ -- "Normal" highlight emitted by the child nvim process. N_child = { @@ -150,7 +149,6 @@ it(':terminal highlight has lower precedence than editor #9964', function() bg_indexed = true, }, }) - screen:attach({ rgb = true }) -- Child nvim process in :terminal (with cterm colors). fn.termopen({ nvim_prog_abs(), @@ -202,7 +200,6 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi [4] = { background = Screen.colors.Grey90, reverse = true }, [5] = { background = Screen.colors.Red }, }) - screen:attach() command(("enew | call termopen(['%s'])"):format(testprg('tty-test'))) screen:expect([[ ^tty ready | @@ -308,7 +305,6 @@ describe(':terminal highlight forwarding', function() [3] = { { fg_indexed = true, foreground = tonumber('0xe0e000') }, { foreground = 3 } }, [4] = { { foreground = tonumber('0xff8000') }, {} }, }) - screen:attach() command(("enew | call termopen(['%s'])"):format(testprg('tty-test'))) feed('i') screen:expect([[ @@ -343,7 +339,7 @@ describe(':terminal highlight with custom palette', function() before_each(function() clear() - screen = Screen.new(50, 7) + screen = Screen.new(50, 7, { rgb = true }) screen:set_default_attr_ids({ [1] = { foreground = tonumber('0x123456') }, -- no fg_indexed when overridden [2] = { foreground = 12 }, @@ -354,7 +350,6 @@ describe(':terminal highlight with custom palette', function() [8] = { background = 11 }, [9] = { bold = true }, }) - screen:attach({ rgb = true }) api.nvim_set_var('terminal_color_3', '#123456') command(("enew | call termopen(['%s'])"):format(testprg('tty-test'))) feed('i') @@ -389,7 +384,6 @@ describe(':terminal', function() screen:add_extra_attr_ids { [100] = { url = 'https://example.com' }, } - screen:attach() local chan = api.nvim_open_term(0, {}) api.nvim_chan_send(chan, '\027]8;;https://example.com\027\\Example\027]8;;\027\\') screen:expect({ diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua @@ -354,8 +354,7 @@ end) describe(':terminal prints more lines than the screen height and exits', function() it('will push extra lines to scrollback', function() clear() - local screen = Screen.new(30, 7) - screen:attach({ rgb = false }) + local screen = Screen.new(30, 7, { rgb = false }) command(("call termopen(['%s', '10']) | startinsert"):format(testprg('tty-test'))) screen:expect([[ line6 | @@ -580,7 +579,6 @@ describe('pending scrollback line handling', function() before_each(function() clear() screen = Screen.new(30, 7) - screen:attach() screen:set_default_attr_ids { [1] = { foreground = Screen.colors.Brown }, [2] = { reverse = true }, diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua @@ -2114,7 +2114,6 @@ describe('TUI', function() [5] = { bold = true, reverse = true }, [6] = { foreground = Screen.colors.White, background = Screen.colors.DarkGreen }, }) - screen:attach() fn.termopen({ nvim_prog, '--clean', @@ -2147,7 +2146,6 @@ describe('TUI', function() for _, guicolors in ipairs({ 'notermguicolors', 'termguicolors' }) do it('has no black flicker when clearing regions during startup with ' .. guicolors, function() local screen = Screen.new(50, 10) - screen:attach() fn.termopen({ nvim_prog, '--clean', diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua @@ -30,10 +30,6 @@ describe(':terminal', function() command('highlight VertSplit NONE') end) - after_each(function() - screen:detach() - end) - it('next to a closing window', function() command('split') command('terminal') diff --git a/test/functional/testterm.lua b/test/functional/testterm.lua @@ -112,7 +112,7 @@ function M.setup_screen(extra_rows, cmd, cols, env, screen_opts) api.nvim_command('highlight StatusLineTerm ctermbg=2 ctermfg=0') api.nvim_command('highlight StatusLineTermNC ctermbg=2 ctermfg=8') - local screen = Screen.new(cols, 7 + extra_rows) + local screen = Screen.new(cols, 7 + extra_rows, screen_opts or { rgb = false }) screen:set_default_attr_ids({ [1] = { reverse = true }, -- focused cursor [2] = { background = 11 }, -- unfocused cursor @@ -134,8 +134,6 @@ function M.setup_screen(extra_rows, cmd, cols, env, screen_opts) [18] = { background = 2, foreground = 8 }, -- StatusLineTermNC }) - screen:attach(screen_opts or { rgb = false }) - api.nvim_command('enew') api.nvim_call_function('termopen', { cmd, env and { env = env } or nil }) api.nvim_input('<CR>') diff --git a/test/functional/treesitter/fold_spec.lua b/test/functional/treesitter/fold_spec.lua @@ -442,7 +442,6 @@ t3]]) it('updates folds in all windows', function() local screen = Screen.new(60, 48) - screen:attach() screen:set_default_attr_ids({ [1] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue }, [2] = { bold = true, foreground = Screen.colors.Blue1 }, @@ -603,7 +602,6 @@ t3]]) it("doesn't open folds in diff mode", function() local screen = Screen.new(60, 36) - screen:attach() parse('c') command( @@ -660,7 +658,6 @@ t3]]) it('does not extend closed fold with `o`/`O`', function() local screen = Screen.new(60, 24) - screen:attach() insert(test_text) parse('c') @@ -727,7 +724,6 @@ t3]]) [3] = { foreground = Screen.colors.Blue1, bold = true }, [4] = { bold = true }, }) - screen:attach() insert([[ # h1 diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua @@ -161,7 +161,6 @@ describe('treesitter highlighting (C)', function() before_each(function() clear() screen = Screen.new(65, 18) - screen:attach() screen:set_default_attr_ids { [1] = { bold = true, foreground = Screen.colors.Blue1 }, [2] = { foreground = Screen.colors.Blue1 }, @@ -848,7 +847,6 @@ describe('treesitter highlighting (lua)', function() before_each(function() clear() screen = Screen.new(65, 18) - screen:attach() screen:set_default_attr_ids { [1] = { bold = true, foreground = Screen.colors.Blue }, [2] = { foreground = Screen.colors.DarkCyan }, @@ -887,7 +885,6 @@ describe('treesitter highlighting (help)', function() before_each(function() clear() screen = Screen.new(40, 6) - screen:attach() screen:set_default_attr_ids { [1] = { foreground = Screen.colors.Blue1 }, [2] = { bold = true, foreground = Screen.colors.Blue1 }, @@ -1025,7 +1022,6 @@ describe('treesitter highlighting (nested injections)', function() before_each(function() clear() screen = Screen.new(80, 7) - screen:attach() screen:set_default_attr_ids { [1] = { foreground = Screen.colors.SlateBlue }, [2] = { bold = true, foreground = Screen.colors.Brown }, @@ -1093,7 +1089,6 @@ describe('treesitter highlighting (markdown)', function() before_each(function() clear() screen = Screen.new(40, 6) - screen:attach() exec_lua(function() vim.bo.filetype = 'markdown' vim.treesitter.start() @@ -1161,7 +1156,6 @@ it('starting and stopping treesitter highlight in init.lua works #29541', functi eq('', api.nvim_get_vvar('errmsg')) local screen = Screen.new(65, 18) - screen:attach() screen:set_default_attr_ids { [1] = { bold = true, foreground = Screen.colors.Blue1 }, [2] = { foreground = Screen.colors.Blue1 }, diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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) }| ^ | diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua @@ -129,8 +129,6 @@ describe('eval-API', function() end) it('use buffer numbers and windows ids as handles', function() - local screen = Screen.new(40, 8) - screen:attach() local bnr = eval("bufnr('')") local bhnd = eval('nvim_get_current_buf()') local wid = eval('win_getid()') @@ -192,7 +190,6 @@ describe('eval-API', function() it('are highlighted by vim.vim syntax file', function() local screen = Screen.new(40, 8) - screen:attach() command('set ft=vim') command('set rtp^=build/runtime/') diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua @@ -189,7 +189,6 @@ describe('uncaught exception', function() it('multiline exception remains multiline #25350', function() local screen = Screen.new(80, 11) - screen:attach() exec_lua([[ function _G.Oops() error("oops") @@ -230,8 +229,7 @@ describe('listing functions using :function', function() end) it('does not crash if another function is deleted while listing', function() - local screen = Screen.new(80, 24) - screen:attach() + local _ = Screen.new(80, 24) matches( 'Vim%(function%):E454: Function list was modified$', pcall_err( @@ -264,8 +262,7 @@ describe('listing functions using :function', function() end) it('does not crash if the same function is deleted while listing', function() - local screen = Screen.new(80, 24) - screen:attach() + local _ = Screen.new(80, 24) matches( 'Vim%(function%):E454: Function list was modified$', pcall_err( diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua @@ -114,7 +114,6 @@ describe('execute()', function() it('does not corrupt the command display #5422', function() local screen = Screen.new(70, 7) - screen:attach() feed(':echo execute("hi ErrorMsg")<CR>') screen:expect( [[ @@ -136,7 +135,6 @@ describe('execute()', function() it('places cursor correctly #6035', function() local screen = Screen.new(40, 6) - screen:attach() source([=[ " test 1: non-silenced output goes as usual function! Test1() @@ -263,7 +261,6 @@ describe('execute()', function() describe('{silent} argument', function() it('captures & displays output for ""', function() local screen = Screen.new(40, 5) - screen:attach() command('let g:mes = execute("echon 42", "")') screen:expect([[ ^ | @@ -287,7 +284,6 @@ describe('execute()', function() it('captures but does not display output for "silent"', function() local screen = Screen.new(40, 5) - screen:attach() command('let g:mes = execute("echon 42")') screen:expect([[ ^ | diff --git a/test/functional/vimscript/has_spec.lua b/test/functional/vimscript/has_spec.lua @@ -4,6 +4,7 @@ local Screen = require('test.functional.ui.screen') local clear = n.clear local connect = n.connect +local get_session = n.get_session local eq = t.eq local fn = n.fn local is_os = t.is_os @@ -74,12 +75,12 @@ describe('has()', function() it('"gui_running"', function() eq(0, fn.has('gui_running')) - local tui = Screen.new(50, 15) + local tui_session = get_session() local gui_session = connect(fn.serverstart()) - local gui = Screen.new(50, 15) eq(0, fn.has('gui_running')) - tui:attach({ ext_linegrid = true, rgb = true, stdin_tty = true, stdout_tty = true }) - gui:attach({ ext_multigrid = true, rgb = true }, gui_session) + local tui = Screen.new(50, 5, { rgb = true, stdin_tty = true, stdout_tty = true }, tui_session) + eq(0, fn.has('gui_running')) + local gui = Screen.new(50, 15, { ext_multigrid = true, rgb = true }, gui_session) eq(1, fn.has('gui_running')) tui:detach() eq(1, fn.has('gui_running')) diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua @@ -17,7 +17,6 @@ local screen before_each(function() clear() screen = Screen.new(25, 5) - screen:attach() source([[ hi Test ctermfg=Red guifg=Red term=bold function CustomCompl(...) diff --git a/test/functional/vimscript/match_functions_spec.lua b/test/functional/vimscript/match_functions_spec.lua @@ -174,7 +174,6 @@ describe('matchaddpos()', function() end) it('works with zero length', function() local screen = Screen.new(40, 5) - screen:attach() fn.setline(1, 'abcdef') command('hi PreProc guifg=Red') eq(4, fn.matchaddpos('PreProc', { { 1, 2, 0 } }, 3, 4)) diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua @@ -132,7 +132,6 @@ describe('system()', function() before_each(function() screen = Screen.new() - screen:attach() end) if is_os('win') then @@ -430,11 +429,6 @@ describe('systemlist()', function() before_each(function() screen = Screen.new() - screen:attach() - end) - - after_each(function() - screen:detach() end) it('`echo` and waits for its return', function() @@ -567,7 +561,6 @@ describe('shell :!', function() it(':{range}! with powershell filter/redirect #16271 #19250', function() local screen = Screen.new(500, 8) - screen:attach() local found = n.set_shell_powershell(true) insert([[ 3 @@ -598,7 +591,6 @@ describe('shell :!', function() it(':{range}! without redirecting to buffer', function() local screen = Screen.new(500, 10) - screen:attach() insert([[ 3 1 diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua @@ -108,7 +108,6 @@ describe('timers', function() it('can invoke redraw in blocking getchar() call', function() local screen = Screen.new(40, 6) - screen:attach() api.nvim_buf_set_lines(0, 0, -1, true, { 'ITEM 1', 'ITEM 2' }) source([[ @@ -225,7 +224,6 @@ describe('timers', function() it("doesn't mess up the cmdline", function() local screen = Screen.new(40, 6) - screen:attach() source([[ let g:val = 0 func! MyHandler(timer) @@ -263,7 +261,6 @@ describe('timers', function() it('can be triggered after an empty string <expr> mapping #17257', function() local screen = Screen.new(40, 6) - screen:attach() command([=[imap <expr> <F2> [timer_start(0, { _ -> execute("throw 'x'", "") }), ''][-1]]=]) feed('i<F2>') screen:expect({ any = 'E605: Exception not caught: x' })