From e61228a214ebda9845db9462dad0a8c362d3963f Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 11 Nov 2024 22:15:19 +0100 Subject: fix(tests): needing two calls to setup a screen is cringe Before calling "attach" a screen object is just a dummy container for (row, col) values whose purpose is to be sent as part of the "attach" function call anyway. Just create the screen in an attached state directly. Keep the complete (row, col, options) config together. It is still completely valid to later detach and re-attach as needed, including to another session. --- test/functional/api/ui_spec.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'test/functional/api/ui_spec.lua') diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua index 2145db7f8a..5976610af1 100644 --- 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') -- cgit