diff options
author | bfredl <bjorn.linse@gmail.com> | 2024-11-11 22:15:19 +0100 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2024-11-14 12:40:57 +0100 |
commit | e61228a214ebda9845db9462dad0a8c362d3963f (patch) | |
tree | fc5908c85c0cc6affc3bc325cd75f6efaeea95d8 /test/functional/ex_cmds | |
parent | 40dee8a2dcba996badaa6182eb34fde1694f92a3 (diff) | |
download | rneovim-e61228a214ebda9845db9462dad0a8c362d3963f.tar.gz rneovim-e61228a214ebda9845db9462dad0a8c362d3963f.tar.bz2 rneovim-e61228a214ebda9845db9462dad0a8c362d3963f.zip |
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.
Diffstat (limited to 'test/functional/ex_cmds')
-rw-r--r-- | test/functional/ex_cmds/append_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/ex_cmds/cmd_map_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/ex_cmds/debug_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/ex_cmds/digraphs_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/ex_cmds/drop_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/ex_cmds/highlight_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/ex_cmds/map_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/ex_cmds/mksession_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/ex_cmds/oldfiles_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/ex_cmds/quickfix_commands_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ex_cmds/swapfile_preserve_recover_spec.lua | 4 |
11 files changed, 3 insertions, 21 deletions
diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua index df62aecc7f..59862d5e77 100644 --- 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 index 6c1ac8eae5..17156e483b 100644 --- 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 index ebb3cdd38a..d657f9aa6d 100644 --- 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 index fde25c028f..c45378e494 100644 --- 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 index 54ddd79a35..d341c823b9 100644 --- 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 index 3cb6cc2579..58709f314f 100644 --- 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 index 9ef0a8ec2e..954dae9335 100644 --- 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 index 8f09e802eb..95e118d570 100644 --- 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 index 927d780181..6f81878f2d 100644 --- 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 index 9c47b1f05f..c1592d85d0 100644 --- 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 index 5bb2a0181e..2820cc9663 100644 --- 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 |