mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
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.
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user