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/ui/inccommand_spec.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index c11e009fef..37dc0f5195 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -66,7 +66,6 @@ local function common_setup(screen, inccommand, text) command('syntax on') command('set nohlsearch') command('hi Substitute guifg=red guibg=yellow') - screen:attach() screen:add_extra_attr_ids { [100] = { underline = true }, @@ -556,10 +555,9 @@ describe(":substitute, 'inccommand' preserves undo", function() end) it('with undolevels=1', function() - local screen = Screen.new(20, 10) - for _, case in pairs(cases) do clear() + local screen = Screen.new(20, 10) common_setup(screen, case, default_text) screen:expect([[ Inc substitution on | @@ -617,10 +615,9 @@ describe(":substitute, 'inccommand' preserves undo", function() end) it('with undolevels=2', function() - local screen = Screen.new(20, 10) - for _, case in pairs(cases) do clear() + local screen = Screen.new(20, 10) common_setup(screen, case, default_text) command('set undolevels=2') @@ -697,10 +694,9 @@ describe(":substitute, 'inccommand' preserves undo", function() end) it('with undolevels=-1', function() - local screen = Screen.new(20, 10) - for _, case in pairs(cases) do clear() + local screen = Screen.new(20, 10) common_setup(screen, case, default_text) command('set undolevels=-1') @@ -728,6 +724,7 @@ describe(":substitute, 'inccommand' preserves undo", function() -- repeat with an interrupted substitution clear() + screen = Screen.new(20, 10) common_setup(screen, case, default_text) command('set undolevels=-1') @@ -2510,7 +2507,7 @@ describe(':substitute', function() end) it("doesn't prompt to swap cmd range", function() - screen = Screen.new(50, 8) -- wide to avoid hit-enter prompt + screen:try_resize(50, 8) -- wide to avoid hit-enter prompt common_setup(screen, 'split', default_text) feed(':2,1s/tw/MO/g') -- cgit