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/lua | |
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/lua')
-rw-r--r-- | test/functional/lua/buffer_updates_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/lua/commands_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/lua/hl_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/lua/loop_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/lua/luaeval_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/lua/overrides_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/lua/secure_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/lua/thread_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/lua/ui_event_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/lua/vim_spec.lua | 8 | ||||
-rw-r--r-- | test/functional/lua/with_spec.lua | 2 |
11 files changed, 1 insertions, 24 deletions
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index f277868b1c..7d034222c8 100644 --- 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 index 456ee13da2..1fd01cfd5a 100644 --- 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 index a123c79ffb..89881973bf 100644 --- 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 index de8200a5f1..0c72843fad 100644 --- 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 index 2b23f72c7d..5fea79141c 100644 --- 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 index 33a2813200..2f332d2c10 100644 --- 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 index c58fd689b7..b40b084ef9 100644 --- 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 index cbf23517dc..310705fd97 100644 --- 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 index 52045b76ff..714332bc2f 100644 --- 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 index 9fd7184cb0..0578d88e66 100644 --- 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 index 99b80ef749..6127e83619 100644 --- 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 = {} |