From 1037ce2e461034a20e35ad59969fd05d5ad68b91 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 9 Dec 2023 20:42:00 +0800 Subject: test: avoid repeated screen lines in expected states This is the command invoked repeatedly to make the changes: :%s/^\(.*\)|\%(\*\(\d\+\)\)\?$\n\1|\%(\*\(\d\+\)\)\?$/\=submatch(1)..'|*'..(max([str2nr(submatch(2)),1])+max([str2nr(submatch(3)),1]))/g --- test/functional/vimscript/api_functions_spec.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'test/functional/vimscript/api_functions_spec.lua') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 0a7e7c1137..66136de1d1 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -182,10 +182,7 @@ describe('eval-API', function() {1:call} {2:bufnr}{3:(}{4:'%'}{3:)} | {1:call} {2:nvim_input}{3:(}{4:'typing...'}{3:)} | {1:call} not_a_function{3:(}{4:42}{3:^)} | - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| + {5:~ }|*4 | ]]) end) -- cgit From b9cf3880455c6ee2c3e9cc9a9d2ad2694c075ec4 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 30 Dec 2023 12:48:05 +0100 Subject: test(functional): remove faulty pending check Problem: `functional/vimscript/api_functions_spec` skips a test if the runtime files are not generated, but this check was broken in a refactor. Solution: Since runtime files are now generated for all test targets, do not skip this test. --- test/functional/vimscript/api_functions_spec.lua | 5 ----- 1 file changed, 5 deletions(-) (limited to 'test/functional/vimscript/api_functions_spec.lua') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 66136de1d1..9a866d0e2d 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -1,6 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local luv = require('luv') local neq, eq, command = helpers.neq, helpers.eq, helpers.command local clear, curbufmeths = helpers.clear, helpers.curbufmeths local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval @@ -156,10 +155,6 @@ describe('eval-API', function() end) it('are highlighted by vim.vim syntax file', function() - if luv.fs_stat("build/runtime/syntax/vim/generated.vim").uid == nil then - pending("runtime was not built, skipping test") - return - end local screen = Screen.new(40, 8) screen:attach() screen:set_default_attr_ids({ -- cgit From 04f2f864e270e772c6326cefdf24947f0130e492 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2024 02:09:18 +0100 Subject: refactor: format test/* --- test/functional/vimscript/api_functions_spec.lua | 146 +++++++++++++---------- 1 file changed, 84 insertions(+), 62 deletions(-) (limited to 'test/functional/vimscript/api_functions_spec.lua') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 9a866d0e2d..05876c43d1 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -11,24 +11,24 @@ local feed = helpers.feed describe('eval-API', function() before_each(clear) - it("work", function() + it('work', function() command("call nvim_command('let g:test = 1')") eq(1, eval("nvim_get_var('test')")) - local buf = eval("nvim_get_current_buf()") - command("call nvim_buf_set_lines("..buf..", 0, -1, v:true, ['aa', 'bb'])") + local buf = eval('nvim_get_current_buf()') + command('call nvim_buf_set_lines(' .. buf .. ", 0, -1, v:true, ['aa', 'bb'])") expect([[ aa bb]]) - command("call nvim_win_set_cursor(0, [1, 1])") + command('call nvim_win_set_cursor(0, [1, 1])') command("call nvim_input('ax')") expect([[ aax bb]]) end) - it("throw errors for invalid arguments", function() + it('throw errors for invalid arguments', function() local err = exc_exec('call nvim_get_current_buf("foo")') eq('Vim(call):E118: Too many arguments for function: nvim_get_current_buf', err) @@ -36,100 +36,121 @@ describe('eval-API', function() eq('Vim(call):E119: Not enough arguments for function: nvim_set_option_value', err) err = exc_exec('call nvim_buf_set_lines(1, 0, -1, [], ["list"])') - eq('Vim(call):E5555: API call: Wrong type for argument 4 when calling nvim_buf_set_lines, expecting Boolean', err) + eq( + 'Vim(call):E5555: API call: Wrong type for argument 4 when calling nvim_buf_set_lines, expecting Boolean', + err + ) err = exc_exec('call nvim_buf_set_lines(0, 0, -1, v:true, "string")') - eq('Vim(call):E5555: API call: Wrong type for argument 5 when calling nvim_buf_set_lines, expecting ArrayOf(String)', err) + eq( + 'Vim(call):E5555: API call: Wrong type for argument 5 when calling nvim_buf_set_lines, expecting ArrayOf(String)', + err + ) err = exc_exec('call nvim_buf_get_number("0")') - eq('Vim(call):E5555: API call: Wrong type for argument 1 when calling nvim_buf_get_number, expecting Buffer', err) + eq( + 'Vim(call):E5555: API call: Wrong type for argument 1 when calling nvim_buf_get_number, expecting Buffer', + err + ) err = exc_exec('call nvim_buf_line_count(17)') eq('Vim(call):E5555: API call: Invalid buffer id: 17', err) end) it('cannot change text or window if textlocked', function() - command("autocmd TextYankPost ++once call nvim_buf_set_lines(0, 0, -1, v:false, [])") - matches('Vim%(call%):E5555: API call: E565: Not allowed to change text or change window$', - pcall_err(command, "normal! yy")) - - command("autocmd TextYankPost ++once call nvim_open_term(0, {})") - matches('Vim%(call%):E5555: API call: E565: Not allowed to change text or change window$', - pcall_err(command, "normal! yy")) + command('autocmd TextYankPost ++once call nvim_buf_set_lines(0, 0, -1, v:false, [])') + matches( + 'Vim%(call%):E5555: API call: E565: Not allowed to change text or change window$', + pcall_err(command, 'normal! yy') + ) + + command('autocmd TextYankPost ++once call nvim_open_term(0, {})') + matches( + 'Vim%(call%):E5555: API call: E565: Not allowed to change text or change window$', + pcall_err(command, 'normal! yy') + ) -- Functions checking textlock should also not be usable from mappings. - command("inoremap nvim_win_close(0, 1)") - eq('Vim(normal):E5555: API call: E565: Not allowed to change text or change window', - pcall_err(command, [[execute "normal i\"]])) + command('inoremap nvim_win_close(0, 1)') + eq( + 'Vim(normal):E5555: API call: E565: Not allowed to change text or change window', + pcall_err(command, [[execute "normal i\"]]) + ) -- Text-changing functions gave a "Failed to save undo information" error when called from an -- mapping outside do_cmdline() (msg_list == NULL), so use feed() to test this. command("inoremap nvim_buf_set_text(0, 0, 0, 0, 0, ['hi'])") meths.set_vvar('errmsg', '') - feed("i") - eq('E5555: API call: E565: Not allowed to change text or change window', - meths.get_vvar('errmsg')) + feed('i') + eq( + 'E5555: API call: E565: Not allowed to change text or change window', + meths.get_vvar('errmsg') + ) -- Some functions checking textlock (usually those that may change the current window or buffer) -- also ought to not be usable in the cmdwin. local old_win = meths.get_current_win() - feed("q:") - eq('E11: Invalid in command-line window; executes, CTRL-C quits', - pcall_err(meths.set_current_win, old_win)) + feed('q:') + eq( + 'E11: Invalid in command-line window; executes, CTRL-C quits', + pcall_err(meths.set_current_win, old_win) + ) -- But others, like nvim_buf_set_lines(), which just changes text, is OK. - curbufmeths.set_lines(0, -1, 1, {"wow!"}) - eq({'wow!'}, curbufmeths.get_lines(0, -1, 1)) + curbufmeths.set_lines(0, -1, 1, { 'wow!' }) + eq({ 'wow!' }, curbufmeths.get_lines(0, -1, 1)) -- Turning the cmdwin buffer into a terminal buffer would be pretty weird. - eq('E11: Invalid in command-line window; executes, CTRL-C quits', - pcall_err(meths.open_term, 0, {})) + eq( + 'E11: Invalid in command-line window; executes, CTRL-C quits', + pcall_err(meths.open_term, 0, {}) + ) -- But turning a different buffer into a terminal from the cmdwin is OK. local term_buf = meths.create_buf(false, true) meths.open_term(term_buf, {}) - eq('terminal', meths.get_option_value("buftype", {buf = term_buf})) + eq('terminal', meths.get_option_value('buftype', { buf = term_buf })) end) - it("use buffer numbers and windows ids as handles", function() + it('use buffer numbers and windows ids as handles', function() local screen = Screen.new(40, 8) screen:attach() local bnr = eval("bufnr('')") - local bhnd = eval("nvim_get_current_buf()") - local wid = eval("win_getid()") - local whnd = eval("nvim_get_current_win()") + local bhnd = eval('nvim_get_current_buf()') + local wid = eval('win_getid()') + local whnd = eval('nvim_get_current_win()') eq(bnr, bhnd) eq(wid, whnd) - command("new") -- creates new buffer and new window + command('new') -- creates new buffer and new window local bnr2 = eval("bufnr('')") - local bhnd2 = eval("nvim_get_current_buf()") - local wid2 = eval("win_getid()") - local whnd2 = eval("nvim_get_current_win()") + local bhnd2 = eval('nvim_get_current_buf()') + local wid2 = eval('win_getid()') + local whnd2 = eval('nvim_get_current_win()') eq(bnr2, bhnd2) eq(wid2, whnd2) neq(bnr, bnr2) neq(wid, wid2) -- 0 is synonymous to the current buffer - eq(bnr2, eval("nvim_buf_get_number(0)")) + eq(bnr2, eval('nvim_buf_get_number(0)')) - command("bn") -- show old buffer in new window - eq(bnr, eval("nvim_get_current_buf()")) + command('bn') -- show old buffer in new window + eq(bnr, eval('nvim_get_current_buf()')) eq(bnr, eval("bufnr('')")) - eq(bnr, eval("nvim_buf_get_number(0)")) - eq(wid2, eval("win_getid()")) - eq(whnd2, eval("nvim_get_current_win()")) + eq(bnr, eval('nvim_buf_get_number(0)')) + eq(wid2, eval('win_getid()')) + eq(whnd2, eval('nvim_get_current_win()')) end) - it("get_lines and set_lines use NL to represent NUL", function() - curbufmeths.set_lines(0, -1, true, {"aa\0", "b\0b"}) - eq({'aa\n', 'b\nb'}, eval("nvim_buf_get_lines(0, 0, -1, 1)")) + it('get_lines and set_lines use NL to represent NUL', function() + curbufmeths.set_lines(0, -1, true, { 'aa\0', 'b\0b' }) + eq({ 'aa\n', 'b\nb' }, eval('nvim_buf_get_lines(0, 0, -1, 1)')) command('call nvim_buf_set_lines(0, 1, 2, v:true, ["xx", "\\nyy"])') - eq({'aa\0', 'xx', '\0yy'}, curbufmeths.get_lines(0, -1, 1)) + eq({ 'aa\0', 'xx', '\0yy' }, curbufmeths.get_lines(0, -1, 1)) end) - it("that are FUNC_ATTR_NOEVAL cannot be called", function() + it('that are FUNC_ATTR_NOEVAL cannot be called', function() -- Deprecated vim_ prefix is not exported. local err = exc_exec('call vim_get_current_buffer("foo")') eq('Vim(call):E117: Unknown function: vim_get_current_buffer', err) @@ -149,25 +170,24 @@ describe('eval-API', function() end) it('have metadata accessible with api_info()', function() - local api_keys = eval("sort(keys(api_info()))") - eq({'error_types', 'functions', 'types', - 'ui_events', 'ui_options', 'version'}, api_keys) + local api_keys = eval('sort(keys(api_info()))') + eq({ 'error_types', 'functions', 'types', 'ui_events', 'ui_options', 'version' }, api_keys) end) it('are highlighted by vim.vim syntax file', function() local screen = Screen.new(40, 8) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Brown}, - [2] = {foreground = Screen.colors.DarkCyan}, - [3] = {foreground = Screen.colors.SlateBlue}, - [4] = {foreground = Screen.colors.Fuchsia}, - [5] = {bold = true, foreground = Screen.colors.Blue}, + [1] = { bold = true, foreground = Screen.colors.Brown }, + [2] = { foreground = Screen.colors.DarkCyan }, + [3] = { foreground = Screen.colors.SlateBlue }, + [4] = { foreground = Screen.colors.Fuchsia }, + [5] = { bold = true, foreground = Screen.colors.Blue }, }) - command("set ft=vim") - command("set rtp^=build/runtime/") - command("syntax on") + command('set ft=vim') + command('set rtp^=build/runtime/') + command('syntax on') insert([[ call bufnr('%') call nvim_input('typing...') @@ -183,9 +203,11 @@ describe('eval-API', function() end) it('cannot be called from sandbox', function() - eq('Vim(call):E48: Not allowed in sandbox', - pcall_err(command, "sandbox call nvim_input('ievil')")) - eq({''}, meths.buf_get_lines(0, 0, -1, true)) + eq( + 'Vim(call):E48: Not allowed in sandbox', + pcall_err(command, "sandbox call nvim_input('ievil')") + ) + eq({ '' }, meths.buf_get_lines(0, 0, -1, true)) end) it('converts blobs to API strings', function() -- cgit From c30f2e3182e3b50e7c03932027ac55edfc8ada4a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 12:44:54 +0000 Subject: test: typing for helpers.meths --- test/functional/vimscript/api_functions_spec.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'test/functional/vimscript/api_functions_spec.lua') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 05876c43d1..6249dcc363 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -80,20 +80,20 @@ describe('eval-API', function() -- Text-changing functions gave a "Failed to save undo information" error when called from an -- mapping outside do_cmdline() (msg_list == NULL), so use feed() to test this. command("inoremap nvim_buf_set_text(0, 0, 0, 0, 0, ['hi'])") - meths.set_vvar('errmsg', '') + meths.nvim_set_vvar('errmsg', '') feed('i') eq( 'E5555: API call: E565: Not allowed to change text or change window', - meths.get_vvar('errmsg') + meths.nvim_get_vvar('errmsg') ) -- Some functions checking textlock (usually those that may change the current window or buffer) -- also ought to not be usable in the cmdwin. - local old_win = meths.get_current_win() + local old_win = meths.nvim_get_current_win() feed('q:') eq( 'E11: Invalid in command-line window; executes, CTRL-C quits', - pcall_err(meths.set_current_win, old_win) + pcall_err(meths.nvim_set_current_win, old_win) ) -- But others, like nvim_buf_set_lines(), which just changes text, is OK. @@ -103,13 +103,13 @@ describe('eval-API', function() -- Turning the cmdwin buffer into a terminal buffer would be pretty weird. eq( 'E11: Invalid in command-line window; executes, CTRL-C quits', - pcall_err(meths.open_term, 0, {}) + pcall_err(meths.nvim_open_term, 0, {}) ) -- But turning a different buffer into a terminal from the cmdwin is OK. - local term_buf = meths.create_buf(false, true) - meths.open_term(term_buf, {}) - eq('terminal', meths.get_option_value('buftype', { buf = term_buf })) + local term_buf = meths.nvim_create_buf(false, true) + meths.nvim_open_term(term_buf, {}) + eq('terminal', meths.nvim_get_option_value('buftype', { buf = term_buf })) end) it('use buffer numbers and windows ids as handles', function() @@ -207,7 +207,7 @@ describe('eval-API', function() 'Vim(call):E48: Not allowed in sandbox', pcall_err(command, "sandbox call nvim_input('ievil')") ) - eq({ '' }, meths.buf_get_lines(0, 0, -1, true)) + eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, true)) end) it('converts blobs to API strings', function() -- cgit From 4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 13:11:28 +0000 Subject: test: normalise nvim bridge functions - remove helpers.cur*meths - remove helpers.nvim --- test/functional/vimscript/api_functions_spec.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/functional/vimscript/api_functions_spec.lua') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 6249dcc363..29841d052a 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local neq, eq, command = helpers.neq, helpers.eq, helpers.command -local clear, curbufmeths = helpers.clear, helpers.curbufmeths +local clear = helpers.clear local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval local insert, pcall_err = helpers.insert, helpers.pcall_err local matches = helpers.matches @@ -97,8 +97,8 @@ describe('eval-API', function() ) -- But others, like nvim_buf_set_lines(), which just changes text, is OK. - curbufmeths.set_lines(0, -1, 1, { 'wow!' }) - eq({ 'wow!' }, curbufmeths.get_lines(0, -1, 1)) + meths.nvim_buf_set_lines(0, 0, -1, 1, { 'wow!' }) + eq({ 'wow!' }, meths.nvim_buf_get_lines(0, 0, -1, 1)) -- Turning the cmdwin buffer into a terminal buffer would be pretty weird. eq( @@ -143,11 +143,11 @@ describe('eval-API', function() end) it('get_lines and set_lines use NL to represent NUL', function() - curbufmeths.set_lines(0, -1, true, { 'aa\0', 'b\0b' }) + meths.nvim_buf_set_lines(0, 0, -1, true, { 'aa\0', 'b\0b' }) eq({ 'aa\n', 'b\nb' }, eval('nvim_buf_get_lines(0, 0, -1, 1)')) command('call nvim_buf_set_lines(0, 1, 2, v:true, ["xx", "\\nyy"])') - eq({ 'aa\0', 'xx', '\0yy' }, curbufmeths.get_lines(0, -1, 1)) + eq({ 'aa\0', 'xx', '\0yy' }, meths.nvim_buf_get_lines(0, 0, -1, 1)) end) it('that are FUNC_ATTR_NOEVAL cannot be called', function() -- cgit From 795f896a5772d5e0795f86642bdf90c82efac45c Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 12 Jan 2024 17:59:57 +0000 Subject: test: rename (meths, funcs) -> (api, fn) --- test/functional/vimscript/api_functions_spec.lua | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'test/functional/vimscript/api_functions_spec.lua') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 29841d052a..200ad40c3a 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -5,7 +5,7 @@ local clear = helpers.clear local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval local insert, pcall_err = helpers.insert, helpers.pcall_err local matches = helpers.matches -local meths = helpers.meths +local api = helpers.api local feed = helpers.feed describe('eval-API', function() @@ -80,36 +80,36 @@ describe('eval-API', function() -- Text-changing functions gave a "Failed to save undo information" error when called from an -- mapping outside do_cmdline() (msg_list == NULL), so use feed() to test this. command("inoremap nvim_buf_set_text(0, 0, 0, 0, 0, ['hi'])") - meths.nvim_set_vvar('errmsg', '') + api.nvim_set_vvar('errmsg', '') feed('i') eq( 'E5555: API call: E565: Not allowed to change text or change window', - meths.nvim_get_vvar('errmsg') + api.nvim_get_vvar('errmsg') ) -- Some functions checking textlock (usually those that may change the current window or buffer) -- also ought to not be usable in the cmdwin. - local old_win = meths.nvim_get_current_win() + local old_win = api.nvim_get_current_win() feed('q:') eq( 'E11: Invalid in command-line window; executes, CTRL-C quits', - pcall_err(meths.nvim_set_current_win, old_win) + pcall_err(api.nvim_set_current_win, old_win) ) -- But others, like nvim_buf_set_lines(), which just changes text, is OK. - meths.nvim_buf_set_lines(0, 0, -1, 1, { 'wow!' }) - eq({ 'wow!' }, meths.nvim_buf_get_lines(0, 0, -1, 1)) + api.nvim_buf_set_lines(0, 0, -1, 1, { 'wow!' }) + eq({ 'wow!' }, api.nvim_buf_get_lines(0, 0, -1, 1)) -- Turning the cmdwin buffer into a terminal buffer would be pretty weird. eq( 'E11: Invalid in command-line window; executes, CTRL-C quits', - pcall_err(meths.nvim_open_term, 0, {}) + pcall_err(api.nvim_open_term, 0, {}) ) -- But turning a different buffer into a terminal from the cmdwin is OK. - local term_buf = meths.nvim_create_buf(false, true) - meths.nvim_open_term(term_buf, {}) - eq('terminal', meths.nvim_get_option_value('buftype', { buf = term_buf })) + local term_buf = api.nvim_create_buf(false, true) + api.nvim_open_term(term_buf, {}) + eq('terminal', api.nvim_get_option_value('buftype', { buf = term_buf })) end) it('use buffer numbers and windows ids as handles', function() @@ -143,11 +143,11 @@ describe('eval-API', function() end) it('get_lines and set_lines use NL to represent NUL', function() - meths.nvim_buf_set_lines(0, 0, -1, true, { 'aa\0', 'b\0b' }) + api.nvim_buf_set_lines(0, 0, -1, true, { 'aa\0', 'b\0b' }) eq({ 'aa\n', 'b\nb' }, eval('nvim_buf_get_lines(0, 0, -1, 1)')) command('call nvim_buf_set_lines(0, 1, 2, v:true, ["xx", "\\nyy"])') - eq({ 'aa\0', 'xx', '\0yy' }, meths.nvim_buf_get_lines(0, 0, -1, 1)) + eq({ 'aa\0', 'xx', '\0yy' }, api.nvim_buf_get_lines(0, 0, -1, 1)) end) it('that are FUNC_ATTR_NOEVAL cannot be called', function() @@ -207,7 +207,7 @@ describe('eval-API', function() 'Vim(call):E48: Not allowed in sandbox', pcall_err(command, "sandbox call nvim_input('ievil')") ) - eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, true)) + eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, true)) end) it('converts blobs to API strings', function() -- cgit From cf140fb25b94c556396fe942a4af3e8db9effa37 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 27 Jul 2023 01:38:23 +0100 Subject: vim-patch:9.1.0047: issues with temp curwin/buf while cmdwin is open Problem: Things that temporarily change/restore curwin/buf (e.g: win_execute, some autocmds) may break assumptions that curwin/buf is the cmdwin when "cmdwin_type != 0", causing issues. Solution: Expose the cmdwin's real win/buf and check that instead. Also try to ensure these variables are NULL if "cmdwin_type == 0", allowing them to be used directly in most cases without checking cmdwin_type. (Sean Dewar) Reset and save `cmdwin_old_curwin` in a similar fashion. Apply suitable changes for API functions and add Lua tests. https://github.com/vim/vim/commit/988f74311c26ea9917e84fbae608de226dba7e5f --- test/functional/vimscript/api_functions_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/functional/vimscript/api_functions_spec.lua') diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua index 200ad40c3a..4985768bb0 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local neq, eq, command = helpers.neq, helpers.eq, helpers.command local clear = helpers.clear local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval +local exec_lua = helpers.exec_lua local insert, pcall_err = helpers.insert, helpers.pcall_err local matches = helpers.matches local api = helpers.api @@ -106,6 +107,19 @@ describe('eval-API', function() pcall_err(api.nvim_open_term, 0, {}) ) + matches( + 'E11: Invalid in command%-line window; executes, CTRL%-C quits$', + pcall_err( + exec_lua, + [[ + local cmdwin_buf = vim.api.nvim_get_current_buf() + vim.api.nvim_buf_call(vim.api.nvim_create_buf(false, true), function() + vim.api.nvim_open_term(cmdwin_buf, {}) + end) + ]] + ) + ) + -- But turning a different buffer into a terminal from the cmdwin is OK. local term_buf = api.nvim_create_buf(false, true) api.nvim_open_term(term_buf, {}) -- cgit