From 743860de40502227b3f0ed64317eb937d24d4a36 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 4 Apr 2023 21:59:06 +0200 Subject: test: replace lfs with luv and vim.fs test: replace lfs with luv luv already pretty much does everything lfs does, so this duplication of dependencies isn't needed. --- test/functional/vimscript/api_functions_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 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 c032ac3030..dc591c3e0d 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local lfs = require('lfs') +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 @@ -118,7 +118,7 @@ describe('eval-API', function() end) it('are highlighted by vim.vim syntax file', function() - if lfs.attributes("build/runtime/syntax/vim/generated.vim",'uid') == nil then + if luv.fs_stat("build/runtime/syntax/vim/generated.vim").uid == nil then pending("runtime was not built, skipping test") return end -- cgit From 1fe1bb084d0099fc4f9bfdc11189485d0f74b75a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 19 Dec 2022 16:37:45 +0000 Subject: refactor(options): deprecate nvim[_buf|_win]_[gs]et_option Co-authored-by: zeertzjq Co-authored-by: famiu --- test/functional/vimscript/api_functions_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 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 dc591c3e0d..3404b06a55 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -32,8 +32,8 @@ describe('eval-API', 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) - err = exc_exec('call nvim_set_option("hlsearch")') - eq('Vim(call):E119: Not enough arguments for function: nvim_set_option', err) + err = exc_exec('call nvim_set_option_value("hlsearch")') + 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) -- cgit From 55f6a1cab031ecc28c5a7f2558a0cac9df2145e1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 30 May 2023 07:18:12 +0800 Subject: vim-patch:9.0.1588: Incsearch not triggered when pasting clipboard register (#23817) Problem: Incsearch not triggered when pasting clipboard register on the command line. Solution: Also set "literally" when using a clipboard register. (Ken Takata, closes vim/vim#12460) https://github.com/vim/vim/commit/9cf6ab133227ac7e9169941752293bb7178d8e38 Co-authored-by: K.Takata --- test/functional/vimscript/api_functions_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 3404b06a55..14678a966d 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -133,7 +133,7 @@ describe('eval-API', function() }) command("set ft=vim") - command("let &rtp='build/runtime/,'.&rtp") + command("set rtp^=build/runtime/") command("syntax on") insert([[ call bufnr('%') -- cgit From 77118d0da8badc4135be430f4cbb15bc95bc760f Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 20 Apr 2023 21:17:25 +0100 Subject: fix(api): use text_locked() to check textlock Problem: some API functions that check textlock (usually those that can change curwin or curbuf) can break the cmdwin. Solution: make FUNC_API_CHECK_TEXTLOCK call text_locked() instead, which already checks for textlock, cmdwin and `` status. Add FUNC_API_TEXTLOCK_ALLOW_CMDWIN to allow such functions to be usable in the cmdwin if they can work properly there; the opt-in nature of this attribute should hopefully help mitigate future bugs. Also fix a regression in #22634 that made functions checking textlock usable in `` mappings, and rename FUNC_API_CHECK_TEXTLOCK to FUNC_API_TEXTLOCK. --- test/functional/vimscript/api_functions_spec.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (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 14678a966d..683ae2446c 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -7,6 +7,7 @@ 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 feed = helpers.feed describe('eval-API', function() before_each(clear) @@ -48,10 +49,25 @@ describe('eval-API', function() eq('Vim(call):E5555: API call: Invalid buffer id: 17', err) end) - it('cannot change texts if textlocked', function() + 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")) + + -- 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\"]])) + + -- Some functions checking textlock (usually those that may change the current window or buffer) + -- also ought to not be usable in the cmdwin. + feed("q:") + eq('E11: Invalid in command-line window; executes, CTRL-C quits', + pcall_err(meths.win_hide, 0)) + + -- 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)) end) it("use buffer numbers and windows ids as handles", function() -- cgit From aa4e47f704c53ab1d825260d2bf34e2872e3ca89 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 23 Jun 2023 22:32:07 +0100 Subject: fix(api): disallow some more functions during textlock Problem: nvim_buf_set_text(), nvim_open_term() and termopen() all change buffer text, which is forbidden during textlock. Additionally, nvim_open_term() and termopen() may be used to convert the cmdwin buffer into a terminal buffer, which is weird. Solution: Allow nvim_buf_set_text() and nvim_open_term() in the cmdwin, but disallow nvim_open_term() from converting the cmdwin buffer into a terminal buffer. termopen() is not allowed in the cmdwin (as it always operates on curbuf), so just check text_locked(). Also happens to improve the error in #21055: nvim_buf_set_text() was callable during textlock, but happened to check textlock indirectly via u_save(); however, this caused the error to be overwritten by an unhelpful "Failed to save undo information" message when msg_list == NULL (e.g: an `` mapping invoked outside of do_cmdline()). --- test/functional/vimscript/api_functions_spec.lua | 21 +++++++++++++++++++++ 1 file changed, 21 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 683ae2446c..6548548a9e 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -54,11 +54,23 @@ describe('eval-API', function() 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\"]])) + -- 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')) + -- Some functions checking textlock (usually those that may change the current window or buffer) -- also ought to not be usable in the cmdwin. feed("q:") @@ -68,6 +80,15 @@ 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)) + + -- 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, {})) + + -- 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})) end) it("use buffer numbers and windows ids as handles", function() -- cgit From 472271199e483d3f23d62c272b20c5290eec5474 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 24 Jul 2023 14:19:01 +0100 Subject: feat(api): allow win_hide to close cmdwin or non-previous windows This aligns its behaviour better with `nvim_win_close`. Note that `:hide` is actually incapable of closing the cmdwin, unlike `:close` and `:quit`, so this is a bit of a difference in behaviour. --- test/functional/vimscript/api_functions_spec.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (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 6548548a9e..0a7e7c1137 100644 --- a/test/functional/vimscript/api_functions_spec.lua +++ b/test/functional/vimscript/api_functions_spec.lua @@ -73,9 +73,10 @@ describe('eval-API', function() -- 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.win_hide, 0)) + 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!"}) -- cgit