diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-11-25 19:15:05 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-11-25 19:27:38 +0000 |
commit | c5d770d311841ea5230426cc4c868e8db27300a8 (patch) | |
tree | dd21f70127b4b8b5f109baefc8ecc5016f507c91 /test/functional/api | |
parent | 9be89f131f87608f224f0ee06d199fcd09d32176 (diff) | |
parent | 081beb3659bd6d8efc3e977a160b1e72becbd8a2 (diff) | |
download | rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.gz rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.tar.bz2 rneovim-c5d770d311841ea5230426cc4c868e8db27300a8.zip |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/functional/api')
-rw-r--r-- | test/functional/api/buffer_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/api/extmark_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/api/menu_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/api/ui_spec.lua | 8 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 44 | ||||
-rw-r--r-- | test/functional/api/window_spec.lua | 6 |
6 files changed, 27 insertions, 49 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index 3775c8c7b7..0cc875bb51 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -125,7 +125,6 @@ describe('api/buf', function() it('cursor position is maintained consistently with viewport', function() local screen = Screen.new(20, 12) - screen:attach() local lines = { 'line1', 'line2', 'line3', 'line4', 'line5', 'line6' } local buf = api.nvim_get_current_buf() @@ -211,7 +210,6 @@ describe('api/buf', function() local screen before_each(function() screen = Screen.new(20, 12) - screen:attach() api.nvim_buf_set_lines( 0, 0, @@ -735,7 +733,6 @@ describe('api/buf', function() it("set_lines of invisible buffer doesn't move cursor in current window", function() local screen = Screen.new(20, 5) - screen:attach() insert([[ Who would win? @@ -1689,7 +1686,6 @@ describe('api/buf', function() it('correctly marks changed region for redraw #13890', function() local screen = Screen.new(20, 5) - screen:attach() insert([[ AAA @@ -1742,7 +1738,6 @@ describe('api/buf', function() local screen before_each(function() screen = Screen.new(20, 12) - screen:attach() api.nvim_buf_set_lines( 0, 0, diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 52d8fd5097..43be0c0e43 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -455,7 +455,6 @@ describe('API/extmarks', function() it('join works when no marks are present', function() screen = Screen.new(15, 10) - screen:attach() feed('a<cr>1<esc>') feed('kJ') -- This shouldn't seg fault @@ -508,7 +507,6 @@ describe('API/extmarks', function() it('marks move with char inserts', function() -- insertchar in edit.c (the ins_str branch) screen = Screen.new(15, 10) - screen:attach() set_extmark(ns, marks[1], 0, 3) feed('0') insert('abc') @@ -759,7 +757,7 @@ describe('API/extmarks', function() { Ïf (!nlua_is_deferred_safe(lstate)) { // strictly not allowed - Яetörn luaL_error(lstate, e_luv_api_disabled, "rpcrequest"); + Яetörn luaL_error(lstate, e_fast_api_disabled, "rpcrequest"); } return nlua_rpc(lstate, true); }]]) @@ -1726,7 +1724,6 @@ describe('API/extmarks', function() it('invalidated marks are deleted', function() screen = Screen.new(40, 6) - screen:attach() feed('dd6iaaa bbb ccc<CR><ESC>gg') api.nvim_set_option_value('signcolumn', 'auto:2', {}) set_extmark(ns, 1, 0, 0, { invalidate = true, sign_text = 'S1', end_row = 1 }) @@ -1811,7 +1808,6 @@ describe('API/extmarks', function() it('respects priority', function() screen = Screen.new(15, 10) - screen:attach() set_extmark(ns, marks[1], 0, 0, { hl_group = 'Comment', @@ -1983,7 +1979,6 @@ describe('API/win_extmark', function() it('sends and only sends ui-watched marks to ui', function() screen = Screen.new(20, 4) - screen:attach() -- should send this set_extmark(ns, marks[1], 1, 0, { ui_watched = true }) -- should not send this @@ -2006,7 +2001,6 @@ describe('API/win_extmark', function() it('sends multiple ui-watched marks to ui', function() screen = Screen.new(20, 4) - screen:attach() feed('15A!<Esc>') -- should send all of these set_extmark(ns, marks[1], 1, 0, { ui_watched = true, virt_text_pos = 'overlay' }) @@ -2052,7 +2046,6 @@ describe('API/win_extmark', function() it('updates ui-watched marks', function() screen = Screen.new(20, 4) - screen:attach() -- should send this set_extmark(ns, marks[1], 1, 0, { ui_watched = true }) -- should not send this @@ -2096,8 +2089,7 @@ describe('API/win_extmark', function() end) it('sends ui-watched to splits', function() - screen = Screen.new(20, 8) - screen:attach({ ext_multigrid = true }) + screen = Screen.new(20, 8, { ext_multigrid = true }) -- should send this set_extmark(ns, marks[1], 1, 0, { ui_watched = true }) -- should not send this diff --git a/test/functional/api/menu_spec.lua b/test/functional/api/menu_spec.lua index 76eef164c9..7556a5bc3f 100644 --- a/test/functional/api/menu_spec.lua +++ b/test/functional/api/menu_spec.lua @@ -11,7 +11,6 @@ describe('update_menu notification', function() before_each(function() clear() screen = Screen.new() - screen:attach() end) local function expect_sent(expected) 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') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index af4d4854f5..3f1e378bc1 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -366,7 +366,6 @@ describe('API', function() it('displays messages when opts.output=false', function() local screen = Screen.new(40, 8) - screen:attach() api.nvim_exec2("echo 'hello'", { output = false }) screen:expect { grid = [[ @@ -379,7 +378,6 @@ describe('API', function() it("doesn't display messages when output=true", function() local screen = Screen.new(40, 6) - screen:attach() api.nvim_exec2("echo 'hello'", { output = true }) screen:expect { grid = [[ @@ -1278,7 +1276,6 @@ describe('API', function() end) it('pasting with empty last chunk in Cmdline mode', function() local screen = Screen.new(20, 4) - screen:attach() feed(':') api.nvim_paste('Foo', true, 1) api.nvim_paste('', true, 3) @@ -1290,7 +1287,6 @@ describe('API', function() end) it('pasting text with control characters in Cmdline mode', function() local screen = Screen.new(20, 4) - screen:attach() feed(':') api.nvim_paste('normal! \023\022\006\027', true, -1) screen:expect([[ @@ -1675,7 +1671,6 @@ describe('API', 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 = [[ @@ -2130,7 +2125,6 @@ describe('API', function() it('does not complete ("interrupt") `d` #3732', function() local screen = Screen.new(20, 4) - screen:attach() command('set listchars=eol:$') command('set list') feed('ia<cr>b<cr>c<cr><Esc>kkk') @@ -2391,7 +2385,6 @@ describe('API', function() before_each(function() screen = Screen.new(40, 8) - screen:attach() end) it('prints long messages correctly #20534', function() @@ -2461,7 +2454,6 @@ describe('API', function() before_each(function() screen = Screen.new(40, 8) - screen:attach() end) it('can show one line', function() @@ -2543,7 +2535,6 @@ describe('API', function() before_each(function() screen = Screen.new(40, 8) - screen:attach() end) it('shows only one return prompt after all lines are shown', function() @@ -3100,8 +3091,7 @@ describe('API', function() eq({}, api.nvim_list_uis()) end) it('returns attached UIs', function() - local screen = Screen.new(20, 4) - screen:attach({ override = true }) + local screen = Screen.new(20, 4, { override = true }) local expected = { { chan = 1, @@ -3129,8 +3119,7 @@ describe('API', function() eq(expected, api.nvim_list_uis()) screen:detach() - screen = Screen.new(44, 99) - screen:attach({ rgb = false }) + screen = Screen.new(44, 99, { rgb = false }) -- luacheck: ignore expected[1].rgb = false expected[1].override = false expected[1].width = 44 @@ -3165,7 +3154,6 @@ describe('API', function() eq(1, api.nvim_get_current_buf()) local screen = Screen.new(20, 4) - screen:attach() api.nvim_buf_set_lines(2, 0, -1, true, { 'some text' }) api.nvim_set_current_buf(2) screen:expect( @@ -3229,7 +3217,6 @@ describe('API', function() eq(1, api.nvim_get_current_buf()) local screen = Screen.new(20, 4) - screen:attach() -- -- Editing a scratch-buffer does NOT change its properties. @@ -3591,11 +3578,19 @@ describe('API', function() before_each(function() screen = Screen.new(40, 8) - screen:attach() command('highlight Statement gui=bold guifg=Brown') command('highlight Special guifg=SlateBlue') end) + it('validation', function() + eq("Invalid 'chunk': expected Array, got String", pcall_err(api.nvim_echo, { 'msg' }, 1, {})) + eq( + 'Invalid chunk: expected Array with 1 or 2 Strings', + pcall_err(api.nvim_echo, { { '', '', '' } }, 1, {}) + ) + eq('Invalid hl_group: text highlight', pcall_err(api.nvim_echo, { { '', false } }, 1, {})) + end) + it('should clear cmdline message before echo', function() feed(':call nvim_echo([["msg"]], v:false, {})<CR>') screen:expect { @@ -3620,6 +3615,18 @@ describe('API', function() msg_a{15:msg_b}{16:msg_c} | ]], } + async_meths.nvim_echo({ + { 'msg_d' }, + { 'msg_e', api.nvim_get_hl_id_by_name('Statement') }, + { 'msg_f', api.nvim_get_hl_id_by_name('Special') }, + }, true, {}) + screen:expect { + grid = [[ + ^ | + {1:~ }|*6 + msg_d{15:msg_e}{16:msg_f} | + ]], + } end) it('can show highlighted multiline', function() @@ -3654,7 +3661,6 @@ describe('API', function() before_each(function() screen = Screen.new(100, 35) - screen:attach() screen:add_extra_attr_ids { [100] = { background = tonumber('0xffff40'), bg_indexed = true }, [101] = { @@ -3933,7 +3939,6 @@ describe('API', function() command('set readonly') eq({ str = '[RO]', width = 4 }, api.nvim_eval_statusline('%r', { maxwidth = 5 })) local screen = Screen.new(80, 24) - screen:attach() command('set showcmd') feed('1234') screen:expect({ any = '1234' }) @@ -4591,7 +4596,6 @@ describe('API', function() end) it('does not interfere with printing line in Ex mode #19400', function() local screen = Screen.new(60, 7) - screen:attach() insert([[ foo bar]]) @@ -5048,7 +5052,6 @@ describe('API', function() it("doesn't display messages when output=true", function() local screen = Screen.new(40, 6) - screen:attach() api.nvim_cmd({ cmd = 'echo', args = { [['hello']] } }, { output = true }) screen:expect { grid = [[ @@ -5131,7 +5134,6 @@ describe('API', function() it('nvim__redraw', function() local screen = Screen.new(60, 5) - screen:attach() eq('at least one action required', pcall_err(api.nvim__redraw, {})) eq('at least one action required', pcall_err(api.nvim__redraw, { buf = 0 })) eq('at least one action required', pcall_err(api.nvim__redraw, { win = 0 })) diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 5ce93f9e04..92999f383a 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -170,7 +170,6 @@ describe('API/win', function() it('updates the screen, and also when the window is unfocused', function() local screen = Screen.new(30, 9) - screen:attach() insert('prologue') feed('100o<esc>') @@ -281,7 +280,6 @@ describe('API/win', function() it('updates cursorline and statusline ruler in non-current window', function() local screen = Screen.new(60, 8) - screen:attach() command('set ruler') command('set cursorline') insert([[ @@ -314,7 +312,6 @@ describe('API/win', function() it('updates cursorcolumn in non-current window', function() local screen = Screen.new(60, 8) - screen:attach() command('set cursorcolumn') insert([[ aaa @@ -857,7 +854,6 @@ describe('API/win', function() it('with two diff windows', function() local X = api.nvim_get_vvar('maxcol') local screen = Screen.new(45, 22) - screen:attach() exec([[ set diffopt+=context:2 number let expr = 'printf("%08d", v:val) .. repeat("!", v:val)' @@ -975,7 +971,6 @@ describe('API/win', function() it('with wrapped lines', function() local X = api.nvim_get_vvar('maxcol') local screen = Screen.new(45, 22) - screen:attach() exec([[ set number cpoptions+=n call setline(1, repeat([repeat('foobar-', 36)], 3)) @@ -2557,7 +2552,6 @@ describe('API/win', function() it('updates statusline when moving bottom split', function() local screen = Screen.new(10, 10) - screen:attach() exec([[ set laststatus=0 belowright split |