From 15a768eeb02e2af39eead1ea1eb4a5a60710d6fb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 22 Aug 2022 18:06:18 +0800 Subject: fix(api): avoid side effects with nvim_parse_cmd (#19890) Save and restore the cursor and last search pattern and do not change search history. --- test/functional/api/vim_spec.lua | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 72a03c409a..24d0b6da45 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3668,6 +3668,55 @@ describe('API', function() :^ | ]]) end) + it('does not move cursor or change search history/pattern #19878 #19890', function() + meths.buf_set_lines(0, 0, -1, true, {'foo', 'bar', 'foo', 'bar'}) + eq({1, 0}, meths.win_get_cursor(0)) + eq('', funcs.getreg('/')) + eq('', funcs.histget('search')) + feed(':') -- call the API in cmdline mode to test whether it changes search history + eq({ + cmd = 'normal', + args = {'x'}, + bang = true, + range = {3, 4}, + count = -1, + reg = '', + addr = 'line', + magic = { + file = false, + bar = false, + }, + nargs = '+', + nextcmd = '', + mods = { + browse = false, + confirm = false, + emsg_silent = false, + filter = { + pattern = "", + force = false, + }, + hide = false, + keepalt = false, + keepjumps = false, + keepmarks = false, + keeppatterns = false, + lockmarks = false, + noautocmd = false, + noswapfile = false, + sandbox = false, + silent = false, + split = "", + tab = 0, + unsilent = false, + verbose = -1, + vertical = false, + } + }, meths.parse_cmd('+2;/bar/normal! x', {})) + eq({1, 0}, meths.win_get_cursor(0)) + eq('', funcs.getreg('/')) + eq('', funcs.histget('search')) + end) end) describe('nvim_cmd', function() it('works', function () -- cgit From 274e1122ade42095cd5b6416e70bda3aa0cb0423 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 25 Aug 2022 17:57:32 +0800 Subject: fix(usercmd): also check for whitespace after escaped character (#19942) --- test/functional/api/command_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua index 890710b6e6..440e93da0e 100644 --- a/test/functional/api/command_spec.lua +++ b/test/functional/api/command_spec.lua @@ -114,8 +114,8 @@ describe('nvim_create_user_command', function() ]] eq({ - args = [[this is a\ test]], - fargs = {"this", "is", "a test"}, + args = [[this\ is a\ test]], + fargs = {"this ", "is", "a test"}, bang = false, line1 = 1, line2 = 1, @@ -144,7 +144,7 @@ describe('nvim_create_user_command', function() count = 2, reg = "", }, exec_lua [=[ - vim.api.nvim_command([[CommandWithLuaCallback this is a\ test]]) + vim.api.nvim_command([[CommandWithLuaCallback this\ is a\ test]]) return result ]=]) -- cgit From fa747d004a1e91b30066020f2f592e4dc5d94084 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 31 Aug 2022 19:47:10 +0800 Subject: fix(api): nvim_set_hl bail out on invalid group name (#20021) --- test/functional/api/highlight_spec.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index 2730f7e23d..3b36563d21 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -354,4 +354,9 @@ describe("API: set highlight", function() meths.set_hl(0, 'Normal', {fg='#000083', bg='#0000F3'}) eq({foreground = 131, background = 243}, nvim("get_hl_by_name", 'Normal', true)) end) + + it('does not segfault on invalid group name #20009', function() + eq('Invalid highlight name: foo bar', pcall_err(meths.set_hl, 0, 'foo bar', {bold = true})) + assert_alive() + end) end) -- cgit From 933c80e8f9d7ff4ab634c14d370440702c7c8ed7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 31 Aug 2022 21:14:14 +0800 Subject: refactor(mappings)!: mapblock_fill_dict() use API Dictionary (#20020) This introduces the following breaking changes: - nvim_get_keymap now always returns a LuaRef object as "callback" for a Lua mapping regardless of how it is called. The LuaRef object can be called from Lua and Vim script, but is lost over RPC. - maparg() now returns a Funcref instead of a ref number as "callback" for a Lua mapping. The Funcref can be called from Lua and Vim script, but is lost over RPC. This may also make nvim_get_keymap faster, but make maparg() slower. --- test/functional/api/keymap_spec.lua | 42 ++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index a93a4544ff..fedcbfa76a 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -6,6 +6,7 @@ local command = helpers.command local curbufmeths = helpers.curbufmeths local eq, neq = helpers.eq, helpers.neq local exec_lua = helpers.exec_lua +local exec = helpers.exec local feed = helpers.feed local funcs = helpers.funcs local meths = helpers.meths @@ -336,21 +337,26 @@ describe('nvim_get_keymap', function() end) it('can handle lua mappings', function() - eq(0, exec_lua [[ + eq(0, exec_lua([[ GlobalCount = 0 - vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() GlobalCount = GlobalCount + 1 end }) + vim.api.nvim_set_keymap('n', 'asdf', '', {callback = function() GlobalCount = GlobalCount + 1 end }) return GlobalCount - ]]) + ]])) feed('asdf\n') - eq(1, exec_lua[[return GlobalCount]]) + eq(1, exec_lua([[return GlobalCount]])) - eq(2, exec_lua[[ + eq(2, exec_lua([[ vim.api.nvim_get_keymap('n')[1].callback() return GlobalCount + ]])) + + exec([[ + call nvim_get_keymap('n')[0].callback() ]]) + eq(3, exec_lua([[return GlobalCount]])) + local mapargs = meths.get_keymap('n') - assert(type(mapargs[1].callback) == 'number', 'callback is not luaref number') mapargs[1].callback = nil eq({ lhs='asdf', @@ -834,17 +840,29 @@ describe('nvim_set_keymap, nvim_del_keymap', function() end) it ('maparg() returns lua mapping correctly', function() - exec_lua [[ - vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() print('jkl;') end }) - ]] - assert.truthy(string.match(funcs.maparg('asdf', 'n'), - "^")) + eq(0, exec_lua([[ + GlobalCount = 0 + vim.api.nvim_set_keymap('n', 'asdf', '', {callback = function() GlobalCount = GlobalCount + 1 end }) + return GlobalCount + ]])) + + assert.truthy(string.match(funcs.maparg('asdf', 'n'), "^")) + local mapargs = funcs.maparg('asdf', 'n', false, true) - assert(type(mapargs.callback) == 'number', 'callback is not luaref number') mapargs.callback = nil mapargs.lhsraw = nil mapargs.lhsrawalt = nil eq(generate_mapargs('n', 'asdf', nil, {sid=sid_lua}), mapargs) + + eq(1, exec_lua([[ + vim.fn.maparg('asdf', 'n', false, true).callback() + return GlobalCount + ]])) + + exec([[ + call maparg('asdf', 'n', v:false, v:true).callback() + ]]) + eq(2, exec_lua([[return GlobalCount]])) end) it('can make lua expr mappings replacing keycodes', function() -- cgit From 689f5d604e59eba1ddab6f91b458a8163dc6629d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 1 Sep 2022 20:32:59 +0800 Subject: feat(api): add support for :horizontal modifier --- test/functional/api/command_spec.lua | 13 +++++++++++-- test/functional/api/vim_spec.lua | 26 ++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua index 440e93da0e..2d8bf23f5b 100644 --- a/test/functional/api/command_spec.lua +++ b/test/functional/api/command_spec.lua @@ -125,6 +125,7 @@ describe('nvim_create_user_command', function() confirm = false, emsg_silent = false, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -160,6 +161,7 @@ describe('nvim_create_user_command', function() confirm = false, emsg_silent = false, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -195,6 +197,7 @@ describe('nvim_create_user_command', function() confirm = false, emsg_silent = false, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -224,12 +227,13 @@ describe('nvim_create_user_command', function() bang = true, line1 = 10, line2 = 10, - mods = "confirm unsilent botright", + mods = "confirm unsilent botright horizontal", smods = { browse = false, confirm = true, emsg_silent = false, hide = false, + horizontal = true, keepalt = false, keepjumps = false, keepmarks = false, @@ -249,7 +253,7 @@ describe('nvim_create_user_command', function() count = 10, reg = "", }, exec_lua [=[ - vim.api.nvim_command('unsilent botright confirm 10CommandWithLuaCallback! h\tey ') + vim.api.nvim_command('unsilent horizontal botright confirm 10CommandWithLuaCallback! h\tey ') return result ]=]) @@ -265,6 +269,7 @@ describe('nvim_create_user_command', function() confirm = false, emsg_silent = false, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -300,6 +305,7 @@ describe('nvim_create_user_command', function() confirm = false, emsg_silent = false, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -347,6 +353,7 @@ describe('nvim_create_user_command', function() confirm = false, emsg_silent = false, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -383,6 +390,7 @@ describe('nvim_create_user_command', function() confirm = false, emsg_silent = false, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -429,6 +437,7 @@ describe('nvim_create_user_command', function() confirm = false, emsg_silent = false, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 24d0b6da45..2e37c4787d 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3195,6 +3195,7 @@ describe('API', function() force = false }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3236,6 +3237,7 @@ describe('API', function() force = false }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3277,6 +3279,7 @@ describe('API', function() force = false }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3318,6 +3321,7 @@ describe('API', function() force = false }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3359,6 +3363,7 @@ describe('API', function() force = false }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3400,6 +3405,7 @@ describe('API', function() force = false }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3441,6 +3447,7 @@ describe('API', function() force = false }, hide = false, + horizontal = true, keepalt = false, keepjumps = false, keepmarks = false, @@ -3456,7 +3463,7 @@ describe('API', function() verbose = 15, vertical = false, }, - }, meths.parse_cmd('15verbose silent! aboveleft topleft tab filter /foo/ split foo.txt', {})) + }, meths.parse_cmd('15verbose silent! horizontal topleft tab filter /foo/ split foo.txt', {})) eq({ cmd = 'split', args = { 'foo.txt' }, @@ -3480,6 +3487,7 @@ describe('API', function() force = true }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3522,6 +3530,7 @@ describe('API', function() force = false }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3563,6 +3572,7 @@ describe('API', function() force = false }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3605,6 +3615,7 @@ describe('API', function() force = false }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3697,6 +3708,7 @@ describe('API', function() force = false, }, hide = false, + horizontal = false, keepalt = false, keepjumps = false, keepmarks = false, @@ -3798,10 +3810,20 @@ describe('API', function() eq('1', meths.cmd({ cmd = 'echomsg', args = { '1' }, mods = { silent = true } }, { output = true })) - -- with :silent message isn't added to message history + -- but message isn't added to message history eq('', meths.cmd({ cmd = 'messages' }, { output = true })) meths.create_user_command("Foo", 'set verbose', {}) eq(" verbose=1", meths.cmd({ cmd = "Foo", mods = { verbose = 1 } }, { output = true })) + meths.create_user_command("Mods", "echo ''", {}) + eq('keepmarks keeppatterns silent 3verbose aboveleft horizontal', + meths.cmd({ cmd = "Mods", mods = { + horizontal = true, + keepmarks = true, + keeppatterns = true, + silent = true, + split = 'aboveleft', + verbose = 3, + } }, { output = true })) eq(0, meths.get_option_value("verbose", {})) command('edit foo.txt | edit bar.txt') eq(' 1 #h "foo.txt" line 1', -- cgit From 1ef7720567b08caec0c077605fb2a01a9d6eafbc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 1 Sep 2022 18:46:34 +0800 Subject: fix(api)!: correctly deal with number before :tab Now nvim_parse_cmd and nvim_create_user_command use a "tab" value which is the same as the number passed before :tab modifier instead of the number plus 1, and "tab" value is -1 if :tab modifier is not used. --- test/functional/api/command_spec.lua | 41 +++++++++++++++++++++++++++--------- test/functional/api/vim_spec.lua | 24 ++++++++++----------- 2 files changed, 43 insertions(+), 22 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua index 2d8bf23f5b..44a19d8348 100644 --- a/test/functional/api/command_spec.lua +++ b/test/functional/api/command_spec.lua @@ -136,7 +136,7 @@ describe('nvim_create_user_command', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -172,7 +172,7 @@ describe('nvim_create_user_command', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -208,7 +208,7 @@ describe('nvim_create_user_command', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -244,7 +244,7 @@ describe('nvim_create_user_command', function() sandbox = false, silent = false, split = "botright", - tab = 0, + tab = -1, unsilent = true, verbose = -1, vertical = false, @@ -280,7 +280,7 @@ describe('nvim_create_user_command', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -316,7 +316,7 @@ describe('nvim_create_user_command', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -364,7 +364,7 @@ describe('nvim_create_user_command', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -401,7 +401,7 @@ describe('nvim_create_user_command', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -448,7 +448,7 @@ describe('nvim_create_user_command', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -523,8 +523,29 @@ describe('nvim_create_user_command', function() vim.api.nvim_cmd({ cmd = 'echo', args = { '&verbose' }, mods = opts.smods }, {}) end, {}) ]] - eq("3", meths.cmd({ cmd = 'MyEcho', mods = { verbose = 3 } }, { output = true })) + + eq(1, #meths.list_tabpages()) + exec_lua[[ + vim.api.nvim_create_user_command('MySplit', function(opts) + vim.api.nvim_cmd({ cmd = 'split', mods = opts.smods }, {}) + end, {}) + ]] + meths.cmd({ cmd = 'MySplit' }, {}) + eq(1, #meths.list_tabpages()) + eq(2, #meths.list_wins()) + meths.cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {}) + eq(2, #meths.list_tabpages()) + eq(2, funcs.tabpagenr()) + meths.cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {}) + eq(3, #meths.list_tabpages()) + eq(2, funcs.tabpagenr()) + meths.cmd({ cmd = 'MySplit', mods = { tab = 3 } }, {}) + eq(4, #meths.list_tabpages()) + eq(4, funcs.tabpagenr()) + meths.cmd({ cmd = 'MySplit', mods = { tab = 0 } }, {}) + eq(5, #meths.list_tabpages()) + eq(1, funcs.tabpagenr()) end) end) diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 2e37c4787d..edbdd54c2f 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3206,7 +3206,7 @@ describe('API', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -3248,7 +3248,7 @@ describe('API', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -3290,7 +3290,7 @@ describe('API', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -3332,7 +3332,7 @@ describe('API', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -3374,7 +3374,7 @@ describe('API', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -3416,7 +3416,7 @@ describe('API', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -3458,7 +3458,7 @@ describe('API', function() sandbox = false, silent = true, split = "topleft", - tab = 2, + tab = 1, unsilent = false, verbose = 15, vertical = false, @@ -3503,7 +3503,7 @@ describe('API', function() verbose = 0, vertical = false, }, - }, meths.parse_cmd('0verbose unsilent botright confirm filter! /foo/ split foo.txt', {})) + }, meths.parse_cmd('0verbose unsilent botright 0tab confirm filter! /foo/ split foo.txt', {})) end) it('works with user commands', function() command('command -bang -nargs=+ -range -addr=lines MyCommand echo foo') @@ -3541,7 +3541,7 @@ describe('API', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -3583,7 +3583,7 @@ describe('API', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -3626,7 +3626,7 @@ describe('API', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, @@ -3719,7 +3719,7 @@ describe('API', function() sandbox = false, silent = false, split = "", - tab = 0, + tab = -1, unsilent = false, verbose = -1, vertical = false, -- cgit From 4dc4cf346755375e49410e16635c00a602b26c36 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Wed, 7 Sep 2022 17:59:27 +0200 Subject: fix(options): mark `winhighlight` as list style (#19477) Also add missing fcs, lcs and winhighlight to list of key-value options for `vim.opt`. Co-authored-by: ii14 --- test/functional/api/vim_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index edbdd54c2f..44775ef85c 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -2732,8 +2732,8 @@ describe('API', function() it('should have information about window options', function() eq({ - allows_duplicates = true, - commalist = false; + allows_duplicates = false, + commalist = true; default = ""; flaglist = false; global_local = false; -- cgit From 2d6735d8cecc587eb5549f65260ee9ddeb8e1d78 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 9 Sep 2022 00:12:42 +0200 Subject: ci: move BSD jobs from sourcehut to Cirrus CI #19616 dispatch.sr.ht is being deprecated, meaning that using sourcehut CI won't be possible (see https://github.com/neovim/neovim/issues/19609). Since Github Actions doesn't provide any BSD runners an external service is required and Cirrus CI seems like a good replacement for sourcehut. Initially experimented with using FreeBSD and OpenBSD virtual machines in GitHub Actions, but Cirrus has been a much better fit with better performance, logs and overall experience. Failing tests are automatically skipped on FreeBSD regardless if it's on CI or not. Ideally these tests should only be skipped in CI with the help of `isCI` helper function. Unfortunately, the tests don't recognize the environment variable CIRRUS_CI even if it's set manually. This workaround is good enough for the time being, but we might want to only skip tests when using the CI (or even better, fix the failing tests). Closes: https://github.com/neovim/neovim/issues/19609 --- test/functional/api/server_notifications_spec.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index 1c00f001ff..1c554b05a3 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -7,6 +7,7 @@ local exec_lua = helpers.exec_lua local retry = helpers.retry local isCI = helpers.isCI local assert_alive = helpers.assert_alive +local uname = helpers.uname describe('notify', function() local channel @@ -78,6 +79,9 @@ describe('notify', function() end) it('cancels stale events on channel close', function() + if uname() == 'freebsd' then + pending('Failing FreeBSD test') + end if isCI() then pending('hangs on CI #14083 #15251') return -- cgit From 35e2c4a2edd28f72c48c70530c5486365c2502a4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 28 Sep 2022 18:27:59 +0800 Subject: fix(lua): fix architecture-dependent behavior in usercmd "reg" (#20384) I don't think using an integer as a NUL-terminated string can work on big-endian systems, at least. This is also not tested. Add a test. Also fix a mistake in the docs of nvim_parse_cmd. --- test/functional/api/command_spec.lua | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua index 44a19d8348..f19d7a362b 100644 --- a/test/functional/api/command_spec.lua +++ b/test/functional/api/command_spec.lua @@ -423,6 +423,7 @@ describe('nvim_create_user_command', function() nargs = 0, bang = true, count = 2, + register = true, }) ]] eq({ @@ -460,6 +461,42 @@ describe('nvim_create_user_command', function() vim.cmd('CommandWithNoArgs') return result ]]) + -- register can be specified + eq({ + args = "", + fargs = {}, + bang = false, + line1 = 1, + line2 = 1, + mods = "", + smods = { + browse = false, + confirm = false, + emsg_silent = false, + hide = false, + horizontal = false, + keepalt = false, + keepjumps = false, + keepmarks = false, + keeppatterns = false, + lockmarks = false, + noautocmd = false, + noswapfile = false, + sandbox = false, + silent = false, + split = "", + tab = -1, + unsilent = false, + verbose = -1, + vertical = false, + }, + range = 0, + count = 2, + reg = "+", + }, exec_lua [[ + vim.cmd('CommandWithNoArgs +') + return result + ]]) end) -- cgit From 45707c1eae62667e5c482a09f6d9a62e01db0e21 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 29 Sep 2022 16:04:14 +0800 Subject: fix(api): fix nvim_cmd crash with filename expansion (#20397) --- test/functional/api/vim_spec.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 44775ef85c..c2f3a5ec5e 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -14,6 +14,7 @@ local funcs = helpers.funcs local iswin = helpers.iswin local meths = helpers.meths local matches = helpers.matches +local pesc = helpers.pesc local mkdir_p = helpers.mkdir_p local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed local is_os = helpers.is_os @@ -3912,11 +3913,23 @@ describe('API', function() eq({'aa'}, meths.buf_get_lines(0, 0, 1, false)) assert_alive() end) + it('supports filename expansion', function() + meths.cmd({ cmd = 'argadd', args = { '%:p:h:t', '%:p:h:t' } }, {}) + local arg = funcs.expand('%:p:h:t') + eq({ arg, arg }, funcs.argv()) + end) it("'make' command works when argument count isn't 1 #19696", function() command('set makeprg=echo') - meths.cmd({ cmd = 'make' }, {}) + command('set shellquote=') + matches('^:!echo ', + meths.cmd({ cmd = 'make' }, { output = true })) + assert_alive() + matches('^:!echo foo bar', + meths.cmd({ cmd = 'make', args = { 'foo', 'bar' } }, { output = true })) assert_alive() - meths.cmd({ cmd = 'make', args = { 'foo', 'bar' } }, {}) + local arg_pesc = pesc(funcs.expand('%:p:h:t')) + matches(('^:!echo %s %s'):format(arg_pesc, arg_pesc), + meths.cmd({ cmd = 'make', args = { '%:p:h:t', '%:p:h:t' } }, { output = true })) assert_alive() end) it('doesn\'t display messages when output=true', function() -- cgit From e46eef75ac2c3336928269e28a1fa138f7327207 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Wed, 28 Sep 2022 17:43:18 +0600 Subject: feat(nvim_cmd): allow using first argument as count Allows `nvim_cmd` to use the first argument as count for applicable commands. Also adds support for non-String arguments to `nvim_cmd`. --- test/functional/api/vim_spec.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index c2f3a5ec5e..ca1c5070a6 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local lfs = require('lfs') +local luv = require('luv') local fmt = string.format local assert_alive = helpers.assert_alive @@ -3962,5 +3963,23 @@ describe('API', function() 15 | ]]} end) + it('works with non-String args', function() + eq('2', meths.cmd({cmd = 'echo', args = {2}}, {output = true})) + eq('1', meths.cmd({cmd = 'echo', args = {true}}, {output = true})) + end) + describe('first argument as count', function() + before_each(clear) + + it('works', function() + command('vsplit | enew') + meths.cmd({cmd = 'bdelete', args = {meths.get_current_buf()}}, {}) + eq(1, meths.get_current_buf().id) + end) + it('works with :sleep using milliseconds', function() + local start = luv.now() + meths.cmd({cmd = 'sleep', args = {'100m'}}, {}) + ok(luv.now() - start <= 300) + end) + end) end) end) -- cgit From cb62592bcb03d7934416cf46bede3b8296254c87 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 27 Sep 2022 14:40:10 +0800 Subject: fix(api)!: nvim_parse_cmd omit "count" "range" "reg" if not supported --- test/functional/api/vim_spec.lua | 66 ++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 22 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index c2f3a5ec5e..703a5fb9e0 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3177,9 +3177,6 @@ describe('API', function() cmd = 'echo', args = { 'foo' }, bang = false, - range = {}, - count = -1, - reg = '', addr = 'none', magic = { file = false, @@ -3220,8 +3217,6 @@ describe('API', function() args = { '/math.random/math.max/' }, bang = false, range = { 4, 6 }, - count = -1, - reg = '', addr = 'line', magic = { file = false, @@ -3263,7 +3258,6 @@ describe('API', function() bang = false, range = { 1 }, count = 1, - reg = '', addr = 'buf', magic = { file = false, @@ -3304,7 +3298,6 @@ describe('API', function() args = {}, bang = false, range = {}, - count = -1, reg = '+', addr = 'line', magic = { @@ -3339,6 +3332,45 @@ describe('API', function() vertical = false, } }, meths.parse_cmd('put +', {})) + eq({ + cmd = 'put', + args = {}, + bang = false, + range = {}, + reg = '', + addr = 'line', + magic = { + file = false, + bar = true + }, + nargs = '0', + nextcmd = '', + mods = { + browse = false, + confirm = false, + emsg_silent = false, + filter = { + pattern = "", + force = false + }, + hide = false, + horizontal = false, + keepalt = false, + keepjumps = false, + keepmarks = false, + keeppatterns = false, + lockmarks = false, + noautocmd = false, + noswapfile = false, + sandbox = false, + silent = false, + split = "", + tab = -1, + unsilent = false, + verbose = -1, + vertical = false, + } + }, meths.parse_cmd('put', {})) end) it('works with range, count and register', function() eq({ @@ -3388,8 +3420,6 @@ describe('API', function() args = {}, bang = true, range = {}, - count = -1, - reg = '', addr = 'line', magic = { file = true, @@ -3430,8 +3460,6 @@ describe('API', function() args = { 'foo.txt' }, bang = false, range = {}, - count = -1, - reg = '', addr = '?', magic = { file = true, @@ -3470,8 +3498,6 @@ describe('API', function() args = { 'foo.txt' }, bang = false, range = {}, - count = -1, - reg = '', addr = '?', magic = { file = true, @@ -3513,8 +3539,6 @@ describe('API', function() args = { 'test', 'it' }, bang = true, range = { 4, 6 }, - count = -1, - reg = '', addr = 'line', magic = { file = false, @@ -3555,8 +3579,6 @@ describe('API', function() args = { 'a.txt' }, bang = false, range = {}, - count = -1, - reg = '', addr = 'arg', magic = { file = true, @@ -3597,9 +3619,6 @@ describe('API', function() cmd = 'MyCommand', args = { 'test it' }, bang = false, - range = {}, - count = -1, - reg = '', addr = 'none', magic = { file = false, @@ -3691,8 +3710,6 @@ describe('API', function() args = {'x'}, bang = true, range = {3, 4}, - count = -1, - reg = '', addr = 'line', magic = { file = false, @@ -3730,6 +3747,11 @@ describe('API', function() eq('', funcs.getreg('/')) eq('', funcs.histget('search')) end) + it('result can be used directly by nvim_cmd #20051', function() + eq("foo", meths.cmd(meths.parse_cmd('echo "foo"', {}), { output = true })) + meths.cmd(meths.parse_cmd("set cursorline", {}), {}) + eq(true, meths.get_option_value("cursorline", {})) + end) end) describe('nvim_cmd', function() it('works', function () -- cgit From df646572c53f55268a5dbb61628d7c3b302d5663 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 30 Sep 2022 09:53:52 +0200 Subject: docs: fix typos (#20394) Co-authored-by: Raphael Co-authored-by: smjonas Co-authored-by: zeertzjq --- test/functional/api/extmark_spec.lua | 22 +++++++++++----------- test/functional/api/keymap_spec.lua | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index bc8d811c6d..00f5b25b8a 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1046,7 +1046,7 @@ describe('API/extmarks', function() check_undo_redo(ns, marks[3], 0, 4, 0, 8) end) - it('substitions over multiple lines with newline in pattern', function() + it('substitutes over multiple lines with newline in pattern', function() feed('A67890xx') set_extmark(ns, marks[1], 0, 3) set_extmark(ns, marks[2], 0, 4) @@ -1078,7 +1078,7 @@ describe('API/extmarks', function() check_undo_redo(ns, marks[6], 1, 2, 0, 5) end) - it('substitions with multiple newlines in pattern', function() + it('substitutes with multiple newlines in pattern', function() feed('A67890xx') set_extmark(ns, marks[1], 0, 4) set_extmark(ns, marks[2], 0, 5) @@ -1093,7 +1093,7 @@ describe('API/extmarks', function() check_undo_redo(ns, marks[5], 2, 0, 0, 6) end) - it('substitions over multiple lines with replace in substition', function() + it('substitutes over multiple lines with replace in substitution', function() feed('A67890xx') set_extmark(ns, marks[1], 0, 1) set_extmark(ns, marks[2], 0, 2) @@ -1111,7 +1111,7 @@ describe('API/extmarks', function() eq({1, 3}, get_extmark_by_id(ns, marks[3])) end) - it('substitions over multiple lines with replace in substition', function() + it('substitutes over multiple lines with replace in substitution', function() feed('Ax3xx') set_extmark(ns, marks[1], 1, 0) set_extmark(ns, marks[2], 1, 1) @@ -1122,7 +1122,7 @@ describe('API/extmarks', function() check_undo_redo(ns, marks[3], 1, 2, 2, 0) end) - it('substitions over multiple lines with replace in substition', function() + it('substitutes over multiple lines with replace in substitution', function() feed('Ax3xx') set_extmark(ns, marks[1], 0, 1) set_extmark(ns, marks[2], 0, 2) @@ -1140,7 +1140,7 @@ describe('API/extmarks', function() check_undo_redo(ns, marks[3], 0, 4, 1, 3) end) - it('substitions with newline in match and sub, delta is 0', function() + it('substitutes with newline in match and sub, delta is 0', function() feed('A67890xx') set_extmark(ns, marks[1], 0, 3) set_extmark(ns, marks[2], 0, 4) @@ -1157,7 +1157,7 @@ describe('API/extmarks', function() check_undo_redo(ns, marks[6], 2, 0, 2, 0) end) - it('substitions with newline in match and sub, delta > 0', function() + it('substitutes with newline in match and sub, delta > 0', function() feed('A67890xx') set_extmark(ns, marks[1], 0, 3) set_extmark(ns, marks[2], 0, 4) @@ -1174,7 +1174,7 @@ describe('API/extmarks', function() check_undo_redo(ns, marks[6], 2, 0, 3, 0) end) - it('substitions with newline in match and sub, delta < 0', function() + it('substitutes with newline in match and sub, delta < 0', function() feed('A67890xxxx') set_extmark(ns, marks[1], 0, 3) set_extmark(ns, marks[2], 0, 4) @@ -1193,7 +1193,7 @@ describe('API/extmarks', function() check_undo_redo(ns, marks[7], 3, 0, 2, 0) end) - it('substitions with backrefs, newline inserted into sub', function() + it('substitutes with backrefs, newline inserted into sub', function() feed('A67890xxxx') set_extmark(ns, marks[1], 0, 3) set_extmark(ns, marks[2], 0, 4) @@ -1210,7 +1210,7 @@ describe('API/extmarks', function() check_undo_redo(ns, marks[6], 2, 0, 3, 0) end) - it('substitions a ^', function() + it('substitutes a ^', function() set_extmark(ns, marks[1], 0, 0) set_extmark(ns, marks[2], 0, 1) feed([[:s:^:x]]) @@ -1397,7 +1397,7 @@ describe('API/extmarks', function() eq({{id, 1, 0}}, bufmeths.get_extmarks(buf, ns, 0, -1, {})) end) - it('does not crash with append/delete/undo seqence', function() + it('does not crash with append/delete/undo sequence', function() meths.exec([[ let ns = nvim_create_namespace('myplugin') call nvim_buf_set_extmark(0, ns, 0, 0, {}) diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index fedcbfa76a..30c351b26a 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -885,7 +885,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() eq({''}, meths.buf_get_lines(0, 0, -1, false)) end) - it('lua expr mapping returning nil is equivalent to returnig an empty string', function() + it('lua expr mapping returning nil is equivalent to returning an empty string', function() exec_lua [[ vim.api.nvim_set_keymap ('i', 'aa', '', {callback = function() return nil end, expr = true }) ]] -- cgit From fc1f84c4c57ba0ba284b0652d412b0402ef928a7 Mon Sep 17 00:00:00 2001 From: bfredl Date: Wed, 5 Oct 2022 11:23:11 +0200 Subject: test(api): migrate screenchar() test in in window API to screen test This produces actual output in case of regressions. --- test/functional/api/window_spec.lua | 106 +++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 32 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 901d24327c..7c65cf9c37 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -15,25 +15,6 @@ local command = helpers.command local pcall_err = helpers.pcall_err local assert_alive = helpers.assert_alive --- check if str is visible at the beginning of some line -local function is_visible(str) - local slen = string.len(str) - local nlines = eval("&lines") - for i = 1,nlines do - local iseq = true - for j = 1,slen do - if string.byte(str,j) ~= eval("screenchar("..i..","..j..")") then - iseq = false - break - end - end - if iseq then - return true - end - end - return false -end - describe('API/win', function() before_each(clear) @@ -79,27 +60,61 @@ describe('API/win', function() end) it('updates the screen, and also when the window is unfocused', function() + local screen = Screen.new(30, 9) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue}, + [2] = {bold = true, reverse = true}; + [3] = {reverse = true}; + }) + screen:attach() + insert("prologue") feed('100o') insert("epilogue") local win = curwin() feed('gg') - poke_eventloop() -- let nvim process the 'gg' command + screen:expect{grid=[[ + ^prologue | + | + | + | + | + | + | + | + | + ]]} -- cursor position is at beginning eq({1, 0}, window('get_cursor', win)) - eq(true, is_visible("prologue")) - eq(false, is_visible("epilogue")) -- move cursor to end window('set_cursor', win, {101, 0}) - eq(false, is_visible("prologue")) - eq(true, is_visible("epilogue")) + screen:expect{grid=[[ + | + | + | + | + | + | + | + ^epilogue | + | + ]]} -- move cursor to the beginning again window('set_cursor', win, {1, 0}) - eq(true, is_visible("prologue")) - eq(false, is_visible("epilogue")) + screen:expect{grid=[[ + ^prologue | + | + | + | + | + | + | + | + | + ]]} -- move focus to new window nvim('command',"new") @@ -107,18 +122,45 @@ describe('API/win', function() -- sanity check, cursor position is kept eq({1, 0}, window('get_cursor', win)) - eq(true, is_visible("prologue")) - eq(false, is_visible("epilogue")) + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {2:[No Name] }| + prologue | + | + | + {3:[No Name] [+] }| + | + ]]} -- move cursor to end window('set_cursor', win, {101, 0}) - eq(false, is_visible("prologue")) - eq(true, is_visible("epilogue")) + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {2:[No Name] }| + | + | + epilogue | + {3:[No Name] [+] }| + | + ]]} -- move cursor to the beginning again window('set_cursor', win, {1, 0}) - eq(true, is_visible("prologue")) - eq(false, is_visible("epilogue")) + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {2:[No Name] }| + prologue | + | + | + {3:[No Name] [+] }| + | + ]]} -- curwin didn't change back neq(win, curwin()) -- cgit From 2a12faaec18115bf057427834832ff20ccb3ffd4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 8 Oct 2022 20:10:00 +0800 Subject: fix(api): dynamically allocate line buffer for nvim_out_write (#20537) --- test/functional/api/vim_spec.lua | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 0b2b371046..909ff80837 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1905,11 +1905,32 @@ describe('API', function() end) end) + describe('nvim_out_write', function() + it('prints long messages correctly #20534', function() + exec([[ + set more + redir => g:out + silent! call nvim_out_write('a') + silent! call nvim_out_write('a') + silent! call nvim_out_write('a') + silent! call nvim_out_write("\n") + silent! call nvim_out_write('a') + silent! call nvim_out_write('a') + silent! call nvim_out_write(repeat('a', 5000) .. "\n") + silent! call nvim_out_write('a') + silent! call nvim_out_write('a') + silent! call nvim_out_write('a') + silent! call nvim_out_write("\n") + redir END + ]]) + eq('\naaa\n' .. ('a'):rep(5002) .. '\naaa', meths.get_var('out')) + end) + end) + describe('nvim_err_write', function() local screen before_each(function() - clear() screen = Screen.new(40, 8) screen:attach() screen:set_default_attr_ids({ -- cgit From 09dffb9db7d16496e55e86f78ab60241533d86f6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 9 Oct 2022 08:21:52 -0400 Subject: docs: various #12823 - increase python line-length limit from 88 => 100. - gen_help_html: fix bug in "tag" case (tbl_count => tbl_contains) ref #15632 fix #18215 fix #18479 fix #20527 fix #20532 Co-authored-by: Ben Weedon --- test/functional/api/vim_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 909ff80837..af6cee7e90 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -2277,7 +2277,7 @@ describe('API', function() eq({'a', '', 'b'}, meths.list_runtime_paths()) meths.set_option('runtimepath', ',a,b') eq({'', 'a', 'b'}, meths.list_runtime_paths()) - -- trailing , is ignored, use ,, if you really really want $CWD + -- Trailing "," is ignored. Use ",," if you really really want CWD. meths.set_option('runtimepath', 'a,b,') eq({'a', 'b'}, meths.list_runtime_paths()) meths.set_option('runtimepath', 'a,b,,') -- cgit From 5046b4b4adb154bbdb50a5e96e29f777b5f807ac Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 17 Oct 2022 17:16:31 +0200 Subject: ci: add cirrus to isCI function to skip tests (#20526) The environment variable CIRRUS_CI is manually passed to RunTests.cmake as it doesn't get passed when using cmake script mode. --- test/functional/api/server_notifications_spec.lua | 4 ---- 1 file changed, 4 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index 1c554b05a3..1c00f001ff 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -7,7 +7,6 @@ local exec_lua = helpers.exec_lua local retry = helpers.retry local isCI = helpers.isCI local assert_alive = helpers.assert_alive -local uname = helpers.uname describe('notify', function() local channel @@ -79,9 +78,6 @@ describe('notify', function() end) it('cancels stale events on channel close', function() - if uname() == 'freebsd' then - pending('Failing FreeBSD test') - end if isCI() then pending('hangs on CI #14083 #15251') return -- cgit From 4716a578ae0c3516d685495bb55e40c939a4ac87 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 23 Oct 2022 10:17:45 +0200 Subject: docs: fix typos --- test/functional/api/keymap_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/api') diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index 30c351b26a..5be4425162 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -1066,7 +1066,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function() eq({'rhs'}, bufmeths.get_lines(0, 0, 1, 1)) end) - it("does not crash when setting keymap in a non-existing buffer #13541", function() + it("does not crash when setting mapping in a non-existing buffer #13541", function() pcall_err(bufmeths.set_keymap, 100, '', 'lsh', 'irhs', {}) helpers.assert_alive() end) -- cgit From 850d7146fc7fb57691641c729d5580b834cd7dd2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Nov 2022 12:43:05 +0800 Subject: fix(paste): feed keys as typed in cmdline mode (#20959) --- test/functional/api/vim_spec.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index af6cee7e90..114413365f 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1108,6 +1108,14 @@ describe('API', function() nvim('paste', 'a', true, -1) eq('a', funcs.getcmdline()) end) + it('pasted text is saved in cmdline history when comes from mapping #20957', function() + command('cnoremap ') + feed(':') + nvim('paste', 'echo', true, -1) + eq('', funcs.histget(':')) + feed('') + eq('echo', funcs.histget(':')) + end) it('pasting with empty last chunk in Cmdline mode', function() local screen = Screen.new(20, 4) screen:attach() -- cgit From c022140ec6a66402e405152054b6ab0141940419 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Mon, 7 Nov 2022 22:27:37 +0600 Subject: feat(api): add command name to Lua command callback opts Adds a `name` key to the opts dict passed to Lua command callbacks created using `nvim_create_user_command()`. This is useful for when multiple commands use the same callback. Note that this kind of behavior is not as strange as one might think, even some internal Neovim commands reuse the same internal C function, differing their behavior by checking the command name. `substitute`, `smagic` and `snomagic` are examples of that. This will also be useful for generalized Lua command preview functions that can preview a wide range of commands, in which case knowing the command name is necessary for the preview function to actually be able to execute the command that it's supposed to preview. --- test/functional/api/command_spec.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua index f19d7a362b..d0fb26edc7 100644 --- a/test/functional/api/command_spec.lua +++ b/test/functional/api/command_spec.lua @@ -114,6 +114,7 @@ describe('nvim_create_user_command', function() ]] eq({ + name = "CommandWithLuaCallback", args = [[this\ is a\ test]], fargs = {"this ", "is", "a test"}, bang = false, @@ -150,6 +151,7 @@ describe('nvim_create_user_command', function() ]=]) eq({ + name = "CommandWithLuaCallback", args = [[this includes\ a backslash: \\]], fargs = {"this", "includes a", "backslash:", "\\"}, bang = false, @@ -186,6 +188,7 @@ describe('nvim_create_user_command', function() ]=]) eq({ + name = "CommandWithLuaCallback", args = "a\\b", fargs = {"a\\b"}, bang = false, @@ -222,6 +225,7 @@ describe('nvim_create_user_command', function() ]=]) eq({ + name = "CommandWithLuaCallback", args = 'h\tey ', fargs = {[[h]], [[ey]]}, bang = true, @@ -258,6 +262,7 @@ describe('nvim_create_user_command', function() ]=]) eq({ + name = "CommandWithLuaCallback", args = "h", fargs = {"h"}, bang = false, @@ -294,6 +299,7 @@ describe('nvim_create_user_command', function() ]]) eq({ + name = "CommandWithLuaCallback", args = "", fargs = {}, -- fargs works without args bang = false, @@ -342,6 +348,7 @@ describe('nvim_create_user_command', function() ]] eq({ + name = "CommandWithOneOrNoArg", args = "hello I'm one argument", fargs = {"hello I'm one argument"}, -- Doesn't split args bang = false, @@ -379,6 +386,7 @@ describe('nvim_create_user_command', function() -- f-args is an empty table if no args were passed eq({ + name = "CommandWithOneOrNoArg", args = "", fargs = {}, bang = false, @@ -427,6 +435,7 @@ describe('nvim_create_user_command', function() }) ]] eq({ + name = "CommandWithNoArgs", args = "", fargs = {}, bang = false, @@ -463,6 +472,7 @@ describe('nvim_create_user_command', function() ]]) -- register can be specified eq({ + name = "CommandWithNoArgs", args = "", fargs = {}, bang = false, -- cgit From 736c36c02f316c979da363c5120495179a2b6c2a Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 13 Nov 2022 14:52:19 +0100 Subject: test: introduce skip() #21010 This is essentially a convenience wrapper around the `pending()` function, similar to `skip_fragile()` but more general-purpose. Also remove `pending_win32` function as it can be replaced by `skip(iswin())`. --- test/functional/api/server_notifications_spec.lua | 9 ++------- test/functional/api/server_requests_spec.lua | 2 +- test/functional/api/vim_spec.lua | 3 ++- 3 files changed, 5 insertions(+), 9 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index 1c00f001ff..77a80ac7f3 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -7,6 +7,7 @@ local exec_lua = helpers.exec_lua local retry = helpers.retry local isCI = helpers.isCI local assert_alive = helpers.assert_alive +local skip = helpers.skip describe('notify', function() local channel @@ -78,13 +79,7 @@ describe('notify', function() end) it('cancels stale events on channel close', function() - if isCI() then - pending('hangs on CI #14083 #15251') - return - elseif helpers.skip_fragile(pending) then - return - end - if helpers.pending_win32(pending) then return end + skip(isCI(), 'hangs on CI #14083 #15251') local catchan = eval("jobstart(['cat'], {'rpc': v:true})") local catpath = eval('exepath("cat")') eq({id=catchan, argv={catpath}, stream='job', mode='rpc', client = {}}, exec_lua ([[ diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index 00a4dd041d..045de94de2 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -250,7 +250,7 @@ describe('server -> client', function() pcall(funcs.jobstop, jobid) end) - if helpers.pending_win32(pending) then return end + if helpers.skip(helpers.iswin()) then return end it('rpc and text stderr can be combined', function() local status, rv = pcall(funcs.rpcrequest, jobid, 'poll') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 114413365f..32b7c349b2 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -30,6 +30,7 @@ local exec_lua = helpers.exec_lua local exc_exec = helpers.exc_exec local insert = helpers.insert local expect_exit = helpers.expect_exit +local skip = helpers.skip local pcall_err = helpers.pcall_err local format_string = helpers.format_string @@ -2729,7 +2730,7 @@ describe('API', function() eq({}, meths.get_runtime_file("foobarlang/", true)) end) it('can handle bad patterns', function() - if helpers.pending_win32(pending) then return end + skip(iswin()) eq("Vim:E220: Missing }.", pcall_err(meths.get_runtime_file, "{", false)) -- cgit From 5c5187c6f809c50e2cfd0ba04961ae8e0d2dabd0 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 14 Nov 2022 09:28:30 +0100 Subject: test: remove skip for 32-bit MSVC (#21030) We don't support 32-bit windows anymore so it's not needed. --- test/functional/api/vim_spec.lua | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 32b7c349b2..7c24f32f74 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -2324,12 +2324,6 @@ describe('API', function() meths.set_option('isident', '') end) - local it_maybe_pending = it - if helpers.isCI() and os.getenv('CONFIGURATION') == 'MSVC_32' then - -- For "works with &opt" (flaky on MSVC_32), but not easy to skip alone. #10241 - it_maybe_pending = pending - end - local function simplify_east_api_node(line, east_api_node) if east_api_node == NIL then return nil @@ -2526,7 +2520,7 @@ describe('API', function() end end require('test.unit.viml.expressions.parser_tests')( - it_maybe_pending, _check_parsing, hl, fmtn) + it, _check_parsing, hl, fmtn) end) describe('nvim_list_uis', function() -- cgit From e8cc489accc435076afb4fdf89778b64f0a48473 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 14 Nov 2022 10:01:35 +0000 Subject: feat(test): add Lua forms for API methods (#20152) --- test/functional/api/buffer_spec.lua | 6 +++--- test/functional/api/vim_spec.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index 8f6fc666c9..598bfeb754 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear, nvim, buffer = helpers.clear, helpers.nvim, helpers.buffer local curbuf, curwin, eq = helpers.curbuf, helpers.curwin, helpers.eq local curbufmeths, ok = helpers.curbufmeths, helpers.ok +local describe_lua_and_rpc = helpers.describe_lua_and_rpc(describe) local meths = helpers.meths local funcs = helpers.funcs local request = helpers.request @@ -579,9 +580,8 @@ describe('api/buf', function() end) end) - describe('nvim_buf_get_text', function() - local get_text = curbufmeths.get_text - + describe_lua_and_rpc('nvim_buf_get_text', function(api) + local get_text = api.curbufmeths.get_text before_each(function() insert([[ hello foo! diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 7c24f32f74..9df73c8d69 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -605,10 +605,10 @@ describe('API', function() eq([[Error loading lua: [string ""]:0: unexpected symbol]], pcall_err(meths.exec_lua, 'aa=bb\0', {})) - eq([[Error executing lua: [string ""]:0: attempt to call global 'bork' (a nil value)]], + eq([[attempt to call global 'bork' (a nil value)]], pcall_err(meths.exec_lua, 'bork()', {})) - eq('Error executing lua: [string ""]:0: did\nthe\nfail', + eq('did\nthe\nfail', pcall_err(meths.exec_lua, 'error("did\\nthe\\nfail")', {})) end) @@ -1149,7 +1149,7 @@ describe('API', function() end) it('vim.paste() failure', function() nvim('exec_lua', 'vim.paste = (function(lines, phase) error("fake fail") end)', {}) - eq([[Error executing lua: [string ""]:0: fake fail]], + eq('fake fail', pcall_err(request, 'nvim_paste', 'line 1\nline 2\nline 3', false, 1)) end) end) -- cgit From f8c671827710c6e9cca3bfd60c32098b2be8239a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 14 Nov 2022 18:04:36 +0000 Subject: feat(lua-api): avoid unnecessary allocations (#19877) Lua makes (or reuses) an internal copy of strings, so we can safely push buf pointers onto the stack. --- test/functional/api/buffer_spec.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index 598bfeb754..5980d99f97 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -186,12 +186,13 @@ describe('api/buf', function() end) end) - describe('nvim_buf_get_lines, nvim_buf_set_lines', function() - local get_lines, set_lines = curbufmeths.get_lines, curbufmeths.set_lines - local line_count = curbufmeths.line_count + describe_lua_and_rpc('nvim_buf_get_lines, nvim_buf_set_lines', function(api) + local get_lines = api.curbufmeths.get_lines + local set_lines = api.curbufmeths.set_lines + local line_count = api.curbufmeths.line_count it('fails correctly when input is not valid', function() - eq(1, curbufmeths.get_number()) + eq(1, api.curbufmeths.get_number()) eq([[String cannot contain newlines]], pcall_err(bufmeths.set_lines, 1, 1, 2, false, {'b\na'})) end) @@ -199,7 +200,7 @@ describe('api/buf', function() it("fails if 'nomodifiable'", function() command('set nomodifiable') eq([[Buffer is not 'modifiable']], - pcall_err(bufmeths.set_lines, 1, 1, 2, false, {'a','b'})) + pcall_err(api.bufmeths.set_lines, 1, 1, 2, false, {'a','b'})) end) it('has correct line_count when inserting and deleting', function() @@ -355,7 +356,7 @@ describe('api/buf', function() Who would win? A real window with proper text]]) - local buf = meths.create_buf(false,true) + local buf = api.meths.create_buf(false,true) screen:expect([[ Who would win? | A real window | @@ -364,7 +365,7 @@ describe('api/buf', function() | ]]) - meths.buf_set_lines(buf, 0, -1, true, {'or some', 'scratchy text'}) + api.meths.buf_set_lines(buf, 0, -1, true, {'or some', 'scratchy text'}) feed('i') -- provoke redraw screen:expect([[ Who would win? | @@ -380,15 +381,15 @@ describe('api/buf', function() visible buffer line 1 line 2 ]]) - local hiddenbuf = meths.create_buf(false,true) + local hiddenbuf = api.meths.create_buf(false,true) command('vsplit') command('vsplit') feed('lll') eq(3, funcs.winnr()) feed('h') eq(2, funcs.winnr()) - meths.buf_set_lines(hiddenbuf, 0, -1, true, - {'hidden buffer line 1', 'line 2'}) + api.meths.buf_set_lines(hiddenbuf, 0, -1, true, + {'hidden buffer line 1', 'line 2'}) feed('p') eq(3, funcs.winnr()) end) -- cgit From fa7e1e26019112ff9e2ea42626995f04e2a4e032 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 15 Nov 2022 21:27:42 +0000 Subject: fix(api): nvim_buf_get_text regression (#21071) --- test/functional/api/buffer_spec.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index 5980d99f97..6b13729994 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -586,7 +586,8 @@ describe('api/buf', function() before_each(function() insert([[ hello foo! - text]]) + text + more]]) end) it('works', function() @@ -594,16 +595,17 @@ describe('api/buf', function() eq({'hello foo!'}, get_text(0, 0, 0, 42, {})) eq({'foo!'}, get_text(0, 6, 0, 10, {})) eq({'foo!', 'tex'}, get_text(0, 6, 1, 3, {})) - eq({'foo!', 'tex'}, get_text(-2, 6, -1, 3, {})) + eq({'foo!', 'tex'}, get_text(-3, 6, -2, 3, {})) eq({''}, get_text(0, 18, 0, 20, {})) - eq({'ext'}, get_text(-1, 1, -1, 4, {})) + eq({'ext'}, get_text(-2, 1, -2, 4, {})) + eq({'hello foo!', 'text', 'm'}, get_text(0, 0, 2, 1, {})) end) it('errors on out-of-range', function() - eq('Index out of bounds', pcall_err(get_text, 2, 0, 3, 0, {})) - eq('Index out of bounds', pcall_err(get_text, -3, 0, 0, 0, {})) - eq('Index out of bounds', pcall_err(get_text, 0, 0, 2, 0, {})) - eq('Index out of bounds', pcall_err(get_text, 0, 0, -3, 0, {})) + eq('Index out of bounds', pcall_err(get_text, 2, 0, 4, 0, {})) + eq('Index out of bounds', pcall_err(get_text, -4, 0, 0, 0, {})) + eq('Index out of bounds', pcall_err(get_text, 0, 0, 3, 0, {})) + eq('Index out of bounds', pcall_err(get_text, 0, 0, -4, 0, {})) -- no ml_get errors should happen #19017 eq('', meths.get_vvar('errmsg')) end) -- cgit From fedf002cb34d0d7a50c54f84a2f161984db2a4c2 Mon Sep 17 00:00:00 2001 From: Jlll1 Date: Thu, 17 Nov 2022 00:18:31 +0100 Subject: fix(api): nvim_win_set_cursor redraw cursorcolumn for non-current window (#21072) fix #19063 this fixes the cursorcolumn not being redrawn for non-current windows in `nvim_win_set_cursor()` --- test/functional/api/window_spec.lua | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 7c65cf9c37..48431ccfc7 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -229,6 +229,46 @@ describe('API/win', function() | ]]) end) + + it('updates cursorcolumn in non-current window', function() + local screen = Screen.new(60, 8) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [2] = {background = Screen.colors.Grey90}, -- CursorColumn + [3] = {bold = true, reverse = true}, -- StatusLine + [4] = {reverse = true}, -- StatusLineNC + }) + screen:attach() + command('set cursorcolumn') + insert([[ + aaa + bbb + ccc + ddd]]) + local oldwin = curwin() + command('vsplit') + screen:expect([[ + aa{2:a} │aa{2:a} | + bb{2:b} │bb{2:b} | + cc{2:c} │cc{2:c} | + dd^d │ddd | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {3:[No Name] [+] }{4:[No Name] [+] }| + | + ]]) + window('set_cursor', oldwin, {2, 0}) + screen:expect([[ + aa{2:a} │{2:a}aa | + bb{2:b} │bbb | + cc{2:c} │{2:c}cc | + dd^d │{2:d}dd | + {1:~ }│{1:~ }| + {1:~ }│{1:~ }| + {3:[No Name] [+] }{4:[No Name] [+] }| + | + ]]) + end) end) describe('{get,set}_height', function() -- cgit From 5eb5f4948826e9d47685ea9e257409cc3e693614 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 22 Nov 2022 01:13:30 +0100 Subject: test: simplify platform detection (#21020) Extend the capabilities of is_os to detect more platforms such as freebsd and openbsd. Also remove `iswin()` helper function as it can be replaced by `is_os("win")`. --- test/functional/api/proc_spec.lua | 4 ++-- test/functional/api/server_notifications_spec.lua | 4 ++-- test/functional/api/server_requests_spec.lua | 2 +- test/functional/api/vim_spec.lua | 11 +++++------ 4 files changed, 10 insertions(+), 11 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/proc_spec.lua b/test/functional/api/proc_spec.lua index 0fbf58a8e7..3af1791e43 100644 --- a/test/functional/api/proc_spec.lua +++ b/test/functional/api/proc_spec.lua @@ -3,12 +3,12 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local eq = helpers.eq local funcs = helpers.funcs -local iswin = helpers.iswin local neq = helpers.neq local nvim_argv = helpers.nvim_argv local request = helpers.request local retry = helpers.retry local NIL = helpers.NIL +local is_os = helpers.is_os describe('API', function() before_each(clear) @@ -62,7 +62,7 @@ describe('API', function() it('returns process info', function() local pid = funcs.getpid() local pinfo = request('nvim_get_proc', pid) - eq((iswin() and 'nvim.exe' or 'nvim'), pinfo.name) + eq((is_os('win') and 'nvim.exe' or 'nvim'), pinfo.name) eq(pid, pinfo.pid) eq('number', type(pinfo.ppid)) neq(pid, pinfo.ppid) diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index 77a80ac7f3..833d54396b 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -5,7 +5,7 @@ local eq, clear, eval, command, nvim, next_msg = local meths = helpers.meths local exec_lua = helpers.exec_lua local retry = helpers.retry -local isCI = helpers.isCI +local is_ci = helpers.is_ci local assert_alive = helpers.assert_alive local skip = helpers.skip @@ -79,7 +79,7 @@ describe('notify', function() end) it('cancels stale events on channel close', function() - skip(isCI(), 'hangs on CI #14083 #15251') + skip(is_ci(), 'hangs on CI #14083 #15251') local catchan = eval("jobstart(['cat'], {'rpc': v:true})") local catpath = eval('exepath("cat")') eq({id=catchan, argv={catpath}, stream='job', mode='rpc', client = {}}, exec_lua ([[ diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index 045de94de2..ceff390dc5 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -250,7 +250,7 @@ describe('server -> client', function() pcall(funcs.jobstop, jobid) end) - if helpers.skip(helpers.iswin()) then return end + if helpers.skip(helpers.is_os('win')) then return end it('rpc and text stderr can be combined', function() local status, rv = pcall(funcs.rpcrequest, jobid, 'poll') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 9df73c8d69..3e1aab28ce 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -12,7 +12,6 @@ local exec = helpers.exec local eval = helpers.eval local expect = helpers.expect local funcs = helpers.funcs -local iswin = helpers.iswin local meths = helpers.meths local matches = helpers.matches local pesc = helpers.pesc @@ -400,7 +399,7 @@ describe('API', function() end) it('returns shell |:!| output', function() - local win_lf = iswin() and '\r' or '' + local win_lf = is_os('win') and '\r' or '' eq(':!echo foo\r\n\nfoo'..win_lf..'\n', nvim('command_output', [[!echo foo]])) end) @@ -2125,7 +2124,7 @@ describe('API', function() pty='?', } local event = meths.get_var("opened_event") - if not iswin() then + if not is_os('win') then info.pty = event.info.pty neq(nil, string.match(info.pty, "^/dev/")) end @@ -2141,7 +2140,7 @@ describe('API', function() stream = 'job', id = 4, argv = ( - iswin() and { + is_os('win') and { eval('&shell'), '/s', '/c', @@ -2163,7 +2162,7 @@ describe('API', function() -- :terminal with args + stopped process. eq(1, eval('jobstop(&channel)')) eval('jobwait([&channel], 1000)') -- Wait. - expected2.pty = (iswin() and '?' or '') -- pty stream was closed. + expected2.pty = (is_os('win') and '?' or '') -- pty stream was closed. eq(expected2, eval('nvim_get_chan_info(&channel)')) end) end) @@ -2724,7 +2723,7 @@ describe('API', function() eq({}, meths.get_runtime_file("foobarlang/", true)) end) it('can handle bad patterns', function() - skip(iswin()) + skip(is_os('win')) eq("Vim:E220: Missing }.", pcall_err(meths.get_runtime_file, "{", false)) -- cgit From 615f124003376c007442319b31a172360796974c Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 29 Nov 2022 02:45:48 +0100 Subject: docs: fix typos (#21196) Co-authored-by: zeertzjq Co-authored-by: Raphael Co-authored-by: Gregory Anders --- test/functional/api/buffer_updates_spec.lua | 2 +- test/functional/api/proc_spec.lua | 10 +++++----- test/functional/api/vim_spec.lua | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index 3d257e9477..d5f06c8f1f 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -810,7 +810,7 @@ describe('API: buffer events:', function() local newlines = args[5] -- Size of the contained nvim instance is 23 lines, this might change - -- with the test setup. Note updates are continguous. + -- with the test setup. Note updates are contiguous. assert(#newlines <= 23) for i = 1,#newlines do diff --git a/test/functional/api/proc_spec.lua b/test/functional/api/proc_spec.lua index 3af1791e43..2028a8fba5 100644 --- a/test/functional/api/proc_spec.lua +++ b/test/functional/api/proc_spec.lua @@ -19,26 +19,26 @@ describe('API', function() -- Might be non-zero already (left-over from some other test?), -- but this is not what is tested here. - local initial_childs = request('nvim_get_proc_children', this_pid) + local initial_children = request('nvim_get_proc_children', this_pid) local job1 = funcs.jobstart(nvim_argv) retry(nil, nil, function() - eq(#initial_childs + 1, #request('nvim_get_proc_children', this_pid)) + eq(#initial_children + 1, #request('nvim_get_proc_children', this_pid)) end) local job2 = funcs.jobstart(nvim_argv) retry(nil, nil, function() - eq(#initial_childs + 2, #request('nvim_get_proc_children', this_pid)) + eq(#initial_children + 2, #request('nvim_get_proc_children', this_pid)) end) funcs.jobstop(job1) retry(nil, nil, function() - eq(#initial_childs + 1, #request('nvim_get_proc_children', this_pid)) + eq(#initial_children + 1, #request('nvim_get_proc_children', this_pid)) end) funcs.jobstop(job2) retry(nil, nil, function() - eq(#initial_childs, #request('nvim_get_proc_children', this_pid)) + eq(#initial_children, #request('nvim_get_proc_children', this_pid)) end) end) diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 3e1aab28ce..5677990525 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3042,7 +3042,7 @@ describe('API', function() meths.buf_set_mark(buf, 'F', 2, 2, {}) meths.buf_set_name(buf, "mybuf") local mark = meths.get_mark('F', {}) - -- Compare the path tail ony + -- Compare the path tail only assert(string.find(mark[4], "mybuf$")) eq({2, 2, buf.id, mark[4]}, mark) end) -- cgit From 982c0053f4059fb4558ce83a0b8d250be1058980 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 2 Dec 2022 10:30:50 +0800 Subject: fix(float): make closing float in another tab return to correct window --- test/functional/api/window_spec.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/functional/api') diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 48431ccfc7..774ec406a8 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -490,6 +490,8 @@ describe('API/win', function() it('closing current (float) window of another tabpage #15313', function() command('tabedit') + command('botright split') + local prevwin = curwin().id eq(2, eval('tabpagenr()')) local win = meths.open_win(0, true, { relative='editor', row=10, col=10, width=50, height=10 @@ -499,7 +501,7 @@ describe('API/win', function() eq(1, eval('tabpagenr()')) meths.win_close(win, false) - eq(1001, meths.tabpage_get_win(tab).id) + eq(prevwin, meths.tabpage_get_win(tab).id) assert_alive() end) end) -- cgit From 224473546c95f17c45afc54fe8b4ef5f0e000974 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 10 Dec 2022 20:13:40 +0800 Subject: fix(api): set correct curbuf when temporarily changing curwin (#21371) This is the same code change as https://github.com/vim/vim/commit/6c87bbb4e45515e70ac1728cabd1451063bf427d --- test/functional/api/window_spec.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 774ec406a8..ecab6a4713 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -7,6 +7,7 @@ local clear, nvim, curbuf, curbuf_contents, window, curwin, eq, neq, helpers.tabpage local poke_eventloop = helpers.poke_eventloop local curwinmeths = helpers.curwinmeths +local exec = helpers.exec local funcs = helpers.funcs local request = helpers.request local NIL = helpers.NIL @@ -283,6 +284,22 @@ describe('API/win', function() window('set_height', nvim('list_wins')[2], 2) eq(2, window('get_height', nvim('list_wins')[2])) end) + + it('do not cause ml_get errors with foldmethod=expr #19989', function() + insert([[ + aaaaa + bbbbb + ccccc]]) + command('set foldmethod=expr') + exec([[ + new + let w = nvim_get_current_win() + wincmd w + call nvim_win_set_height(w, 5) + ]]) + feed('l') + eq('', meths.get_vvar('errmsg')) + end) end) describe('{get,set}_width', function() @@ -297,6 +314,22 @@ describe('API/win', function() window('set_width', nvim('list_wins')[2], 2) eq(2, window('get_width', nvim('list_wins')[2])) end) + + it('do not cause ml_get errors with foldmethod=expr #19989', function() + insert([[ + aaaaa + bbbbb + ccccc]]) + command('set foldmethod=expr') + exec([[ + vnew + let w = nvim_get_current_win() + wincmd w + call nvim_win_set_width(w, 5) + ]]) + feed('l') + eq('', meths.get_vvar('errmsg')) + end) end) describe('{get,set,del}_var', function() -- cgit From ea8b82890179be4243902d88a5241bbc33122aad Mon Sep 17 00:00:00 2001 From: Jon Huhn Date: Sat, 10 Dec 2022 15:46:34 -0600 Subject: fix(tests): initialize Screen.colors in API highlight tests --- test/functional/api/highlight_spec.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index 3b36563d21..541ac0ab63 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -11,6 +11,9 @@ local ok = helpers.ok local assert_alive = helpers.assert_alive describe('API: highlight',function() + clear() + Screen.new() -- initialize Screen.colors + local expected_rgb = { background = Screen.colors.Yellow, foreground = Screen.colors.Red, -- cgit From 1c324cb1927e03b5a3584a8982e3d5029498f14e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 11 Dec 2022 21:41:26 -0500 Subject: docs #20986 - https://github.com/neovim/tree-sitter-vimdoc v1.2.4 eliminates most errors in pi_netrw.txt, so we can remove that workaround from ignore_parse_error(). - improved codeblock --- test/functional/api/autocmd_spec.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index a923f5df0e..7fb52b097b 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -14,14 +14,14 @@ before_each(clear) describe('autocmd api', function() describe('nvim_create_autocmd', function() - it('does not allow "command" and "callback" in the same autocmd', function() - local ok, _ = pcall(meths.create_autocmd, "BufReadPost", { + it('"command" and "callback" are mutually exclusive', function() + local rv = pcall_err(meths.create_autocmd, "BufReadPost", { pattern = "*.py,*.pyi", command = "echo 'Should Have Errored", - callback = "not allowed", + callback = "NotAllowed", }) - eq(false, ok) + eq("specify either 'callback' or 'command', not both", rv) end) it('doesnt leak when you use ++once', function() @@ -60,13 +60,13 @@ describe('autocmd api', function() end) it('does not allow passing buffer and patterns', function() - local ok = pcall(meths.create_autocmd, "Filetype", { + local rv = pcall_err(meths.create_autocmd, "Filetype", { command = "let g:called = g:called + 1", buffer = 0, pattern = "*.py", }) - eq(false, ok) + eq("cannot pass both: 'pattern' and 'buffer' for the same autocmd", rv) end) it('does not allow passing invalid buffers', function() -- cgit From 72a19b2ffe93ab20f6ff1825e11b43da4e44842a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 16 Dec 2022 08:54:13 +0800 Subject: fix(api): "emsg_silent" should imply "silent" in nvim_cmd (#21438) --- test/functional/api/vim_spec.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 5677990525..531b9cc2c1 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3853,14 +3853,16 @@ describe('API', function() eq("", meths.cmd({ cmd = "Foo", bang = false }, { output = true })) end) it('works with modifiers', function() - -- with :silent output is still captured + -- with silent = true output is still captured eq('1', meths.cmd({ cmd = 'echomsg', args = { '1' }, mods = { silent = true } }, { output = true })) -- but message isn't added to message history eq('', meths.cmd({ cmd = 'messages' }, { output = true })) + meths.create_user_command("Foo", 'set verbose', {}) eq(" verbose=1", meths.cmd({ cmd = "Foo", mods = { verbose = 1 } }, { output = true })) + meths.create_user_command("Mods", "echo ''", {}) eq('keepmarks keeppatterns silent 3verbose aboveleft horizontal', meths.cmd({ cmd = "Mods", mods = { @@ -3872,6 +3874,7 @@ describe('API', function() verbose = 3, } }, { output = true })) eq(0, meths.get_option_value("verbose", {})) + command('edit foo.txt | edit bar.txt') eq(' 1 #h "foo.txt" line 1', meths.cmd({ cmd = "buffers", mods = { filter = { pattern = "foo", force = false } } }, @@ -3879,6 +3882,13 @@ describe('API', function() eq(' 2 %a "bar.txt" line 1', meths.cmd({ cmd = "buffers", mods = { filter = { pattern = "foo", force = true } } }, { output = true })) + + -- with emsg_silent = true error is suppresed + feed([[:lua vim.api.nvim_cmd({ cmd = 'call', mods = { emsg_silent = true } }, {})]]) + eq('', meths.cmd({ cmd = 'messages' }, { output = true })) + -- error from the next command typed is not suppressed #21420 + feed(':call') + eq('E471: Argument required', meths.cmd({ cmd = 'messages' }, { output = true })) end) it('works with magic.file', function() exec_lua([[ -- cgit From 146c428a533b649adbc95fc29b41af42624b6ece Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 27 Dec 2022 18:04:42 +0800 Subject: fix(statusline): make nvim_eval_statusline() work with %S (#21553) --- test/functional/api/vim_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 531b9cc2c1..98bfb83dbd 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3126,6 +3126,19 @@ describe('API', function() eq('E539: Illegal character <}>', pcall_err(meths.eval_statusline, '%{%}', {})) end) + it('supports %S item', function() + local screen = Screen.new(80, 24) + screen:attach() + command('set showcmd') + feed('1234') + screen:expect({any = '1234'}) + eq({ str = '1234', width = 4 }, + meths.eval_statusline('%S', { maxwidth = 5 })) + feed('56') + screen:expect({any = '123456'}) + eq({ str = '<3456', width = 5 }, + meths.eval_statusline('%S', { maxwidth = 5 })) + end) describe('highlight parsing', function() it('works', function() eq({ -- cgit From 9b1112cf48238260b170b8763b18a02a58159c2a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 10 Jan 2023 21:18:12 +0800 Subject: fix(statuscolumn): fix crashes and clang/PVS warnings (#21725) --- test/functional/api/vim_spec.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 98bfb83dbd..aa2f46bb59 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3126,7 +3126,12 @@ describe('API', function() eq('E539: Illegal character <}>', pcall_err(meths.eval_statusline, '%{%}', {})) end) - it('supports %S item', function() + it('supports various items', function() + eq({ str = '0', width = 1 }, + meths.eval_statusline('%l', { maxwidth = 5 })) + command('set readonly') + eq({ str = '[RO]', width = 4 }, + meths.eval_statusline('%r', { maxwidth = 5 })) local screen = Screen.new(80, 24) screen:attach() command('set showcmd') -- cgit From 921e634119c14b03f9611f1602df171c9ffc9559 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Thu, 12 Jan 2023 16:25:44 +0100 Subject: fix(api): nvim_create_autocmd crash on invalid types inside pattern array Co-authored-by: ii14 --- test/functional/api/autocmd_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index 7fb52b097b..22a1311ee9 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -613,6 +613,20 @@ describe('autocmd api', function() eq(false, success) matches("'group' must be a string or an integer", code) end) + + it('raises error for invalid pattern array', function() + local success, code = unpack(meths.exec_lua([[ + return {pcall(function() + vim.api.nvim_create_autocmd("FileType", { + pattern = {{}}, + command = "echo 'hello'", + }) + end)} + ]], {})) + + eq(false, success) + matches("All entries in 'pattern' must be strings", code) + end) end) describe('patterns', function() -- cgit From 61d5bd561addfd4cc9917712bdf983e77137089e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 16 Jan 2023 06:38:50 +0800 Subject: refactor: remove E5500, adjust tests Now with try_end() including more exception info, E5500 looks like redundant information. Adjust tests for more exception information. --- test/functional/api/vim_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index aa2f46bb59..68003e918b 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -166,7 +166,7 @@ describe('API', function() echo nvim_exec('echo Avast_ye_hades(''ahoy!'')', 1) ]], true)) - eq('Vim(call):E5555: API call: Vim(echo):E121: Undefined variable: s:pirate', + matches('Vim%(echo%):E121: Undefined variable: s:pirate$', pcall_err(request, 'nvim_exec', [[ let s:pirate = 'script-scoped varrrrr' call nvim_exec('echo s:pirate', 1) @@ -208,12 +208,12 @@ describe('API', function() end) it('execution error', function() - eq('Vim:E492: Not an editor command: bogus_command', + eq('nvim_exec(): Vim:E492: Not an editor command: bogus_command', pcall_err(request, 'nvim_exec', 'bogus_command', false)) eq('', nvim('eval', 'v:errmsg')) -- v:errmsg was not updated. eq('', eval('v:exception')) - eq('Vim(buffer):E86: Buffer 23487 does not exist', + eq('nvim_exec(): Vim(buffer):E86: Buffer 23487 does not exist', pcall_err(request, 'nvim_exec', 'buffer 23487', false)) eq('', eval('v:errmsg')) -- v:errmsg was not updated. eq('', eval('v:exception')) @@ -485,7 +485,7 @@ describe('API', function() throw 'wtf' endfunction ]]) - eq('wtf', pcall_err(request, 'nvim_call_function', 'Foo', {})) + eq('function Foo, line 1: wtf', pcall_err(request, 'nvim_call_function', 'Foo', {})) eq('', eval('v:exception')) eq('', eval('v:errmsg')) -- v:errmsg was not updated. end) -- cgit From 6ec7bcb6184f562157eebc8d0f25f78ba333c6a5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 16 Jan 2023 20:43:13 +0100 Subject: test: avoid noise in NVIM_LOG_FILE Problem: Tests that _intentionally_ fail certain conditions cause noise in $NVIM_LOG_FILE: $NVIM_LOG_FILE: /home/runner/work/neovim/neovim/build/.nvimlog (last 100 lines) WRN 2023-01-16T18:26:27.673 T599.7799.0 unsubscribe:519: RPC: ch 1: tried to unsubscribe unknown event 'doesnotexist' WRN 2023-01-16T18:29:00.557 ?.11151 server_start:163: Failed to start server: no such file or directory: /X/X/X/... WRN 2023-01-16T18:33:07.269 127.0.0.1:12345 server_start:163: Failed to start server: address already in use: 127.0.0.1 ... -- Output to stderr: module 'vim.shared' not found: no field package.preload['vim.shared'] no file './vim/shared.lua' no file '/home/runner/nvim-deps/usr/share/lua/5.1/vim/shared.lua' no file '/home/runner/nvim-deps/usr/share/lua/5.1/vim/shared/init.lua' no file '/home/runner/nvim-deps/usr/lib/lua/5.1/vim/shared.lua' no file '/home/runner/nvim-deps/usr/lib/lua/5.1/vim/shared/init.lua' no file './vim/shared.so' ... E970: Failed to initialize builtin lua modules Solution: - Log to a private $NVIM_LOG_FILE in tests that intentionally fail and cause ERR log messages. - Assert that the expected messages are actually logged. --- test/functional/api/server_notifications_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index 833d54396b..1ee2e5a517 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -1,4 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) +local assert_log = helpers.assert_log local eq, clear, eval, command, nvim, next_msg = helpers.eq, helpers.clear, helpers.eval, helpers.command, helpers.nvim, helpers.next_msg @@ -9,6 +10,8 @@ local is_ci = helpers.is_ci local assert_alive = helpers.assert_alive local skip = helpers.skip +local testlog = 'Xtest-server-notify-log' + describe('notify', function() local channel @@ -17,6 +20,10 @@ describe('notify', function() channel = nvim('get_api_info')[1] end) + after_each(function() + os.remove(testlog) + end) + describe('passing a valid channel id', function() it('sends the notification/args to the corresponding channel', function() eval('rpcnotify('..channel..', "test-event", 1, 2, 3)') @@ -72,8 +79,14 @@ describe('notify', function() end) it('unsubscribe non-existing event #8745', function() + clear{env={ + NVIM_LOG_FILE=testlog, + }} nvim('subscribe', 'event1') nvim('unsubscribe', 'doesnotexist') + retry(nil, 1000, function() + assert_log("tried to unsubscribe unknown event 'doesnotexist'", testlog, 10) + end) nvim('unsubscribe', 'event1') assert_alive() end) -- cgit From 665a7dafaf892b31285f35a43a90fc6e968fd7da Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 17 Jan 2023 00:12:59 +0100 Subject: refactor(tests): lift retry() into assert_log() --- test/functional/api/server_notifications_spec.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index 1ee2e5a517..53642858b2 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -84,9 +84,7 @@ describe('notify', function() }} nvim('subscribe', 'event1') nvim('unsubscribe', 'doesnotexist') - retry(nil, 1000, function() - assert_log("tried to unsubscribe unknown event 'doesnotexist'", testlog, 10) - end) + assert_log("tried to unsubscribe unknown event 'doesnotexist'", testlog, 10) nvim('unsubscribe', 'event1') assert_alive() end) -- cgit From da3460562e84dcf608248cc9a5b0eb2341531a0d Mon Sep 17 00:00:00 2001 From: luukvbaal <31730729+luukvbaal@users.noreply.github.com> Date: Tue, 17 Jan 2023 00:31:36 +0100 Subject: fix(api): avoid memory leak with click functions in nvim_eval_statusline() (#21845) Problem: Allocated click function memory is lost due to `nvim_eval_statusline()` not passing in a `StlClickRecord`. Solution: Do not allocate click function memory if `tabtab == NULL`. Resolve #21764, supersede #21842. --- test/functional/api/vim_spec.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 68003e918b..d1314216e2 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3211,6 +3211,17 @@ describe('API', function() 'TextWithNoHighlight%#WarningMsg#TextWithWarningHighlight', { use_winbar = true, highlights = true })) end) + it('no memory leak with click functions', function() + meths.eval_statusline('%@ClickFunc@StatusLineStringWithClickFunc%T', {}) + eq({ + str = 'StatusLineStringWithClickFunc', + width = 29 + }, + meths.eval_statusline( + '%@ClickFunc@StatusLineStringWithClickFunc%T', + {}) + ) + end) end) end) describe('nvim_parse_cmd', function() -- cgit From 3b7548504344d72b0228e1bd29a7f28df813a3bd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 23 Jan 2023 19:32:27 +0800 Subject: revert: "shada/context: fully remove jumplist duplicates #10898" (#21874) This reverts commit 8b8ecf44f2cda43bbd710ec22ef99439b71888cd. It is causing performance problems on exit. Fix #21082. --- test/functional/api/vim_spec.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index d1314216e2..8fcdd9620b 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1807,9 +1807,11 @@ describe('API', function() }, ['jumps'] = eval(([[ - filter(map(getjumplist()[0], 'filter( - { "f": expand("#".v:val.bufnr.":p"), "l": v:val.lnum }, - { k, v -> k != "l" || v != 1 })'), '!empty(v:val.f)') + filter(map(add( + getjumplist()[0], { 'bufnr': bufnr('%'), 'lnum': getcurpos()[1] }), + 'filter( + { "f": expand("#".v:val.bufnr.":p"), "l": v:val.lnum }, + { k, v -> k != "l" || v != 1 })'), '!empty(v:val.f)') ]]):gsub('\n', '')), ['bufs'] = eval([[ -- cgit From f5d357de553c1aa61cdb25b047f984f6414b1967 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Thu, 19 Jan 2023 17:51:56 +0000 Subject: refactor(highlight): reshape the HL_UNDER* bits into a 3-bit integer mask Saves two bits for reuse for new features --- test/functional/api/highlight_spec.lua | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index 541ac0ab63..8510eb6094 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -32,13 +32,15 @@ describe('API: highlight',function() italic = true, reverse = true, underline = true, - undercurl = true, - underdouble = true, - underdotted = true, - underdashed = true, strikethrough = true, nocombine = true, } + local expected_undercurl = { + background = Screen.colors.Yellow, + foreground = Screen.colors.Red, + special = Screen.colors.Blue, + undercurl = true, + } before_each(function() clear() @@ -59,9 +61,13 @@ describe('API: highlight',function() eq('Invalid highlight id: 30000', string.match(emsg, 'Invalid.*')) -- Test all highlight properties. - command('hi NewHighlight gui=underline,bold,undercurl,underdouble,underdotted,underdashed,italic,reverse,strikethrough,nocombine') + command('hi NewHighlight gui=underline,bold,italic,reverse,strikethrough,nocombine') eq(expected_rgb2, nvim("get_hl_by_id", hl_id, true)) + -- Test undercurl + command('hi NewHighlight gui=undercurl') + eq(expected_undercurl, nvim("get_hl_by_id", hl_id, true)) + -- Test nil argument. err, emsg = pcall(meths.get_hl_by_id, { nil }, false) eq(false, err) @@ -207,16 +213,11 @@ describe("API: set highlight", function() bold = true, italic = true, reverse = true, - undercurl = true, underline = true, - underdashed = true, - underdotted = true, - underdouble = true, strikethrough = true, cterm = { italic = true, reverse = true, - undercurl = true, strikethrough = true, nocombine = true, } @@ -227,11 +228,7 @@ describe("API: set highlight", function() bold = true, italic = true, reverse = true, - undercurl = true, underline = true, - underdashed = true, - underdotted = true, - underdouble = true, strikethrough = true, } local highlight3_result_cterm = { @@ -239,7 +236,6 @@ describe("API: set highlight", function() foreground = highlight_color.ctermfg, italic = true, reverse = true, - undercurl = true, strikethrough = true, nocombine = true, } @@ -296,7 +292,7 @@ describe("API: set highlight", function() exec_capture('highlight Test_hl')) meths.set_hl(0, 'Test_hl2', highlight3_config) - eq('Test_hl2 xxx cterm=undercurl,italic,reverse,strikethrough,nocombine ctermfg=8 ctermbg=15 gui=bold,underline,undercurl,underdouble,underdotted,underdashed,italic,reverse,strikethrough guifg=#ff0000 guibg=#0032aa', + eq('Test_hl2 xxx cterm=italic,reverse,strikethrough,nocombine ctermfg=8 ctermbg=15 gui=bold,underline,italic,reverse,strikethrough guifg=#ff0000 guibg=#0032aa', exec_capture('highlight Test_hl2')) -- Colors are stored with the name they are defined, but -- cgit From f3039ce531f49a63f8fd07317c1f957fb28fc6a7 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Thu, 19 Jan 2023 23:18:21 +0000 Subject: feat(highlight): define the concept of altfont as a (c)term rendering attribute --- test/functional/api/highlight_spec.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index 8510eb6094..5941d4c68b 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -33,6 +33,7 @@ describe('API: highlight',function() reverse = true, underline = true, strikethrough = true, + altfont = true, nocombine = true, } local expected_undercurl = { @@ -61,7 +62,7 @@ describe('API: highlight',function() eq('Invalid highlight id: 30000', string.match(emsg, 'Invalid.*')) -- Test all highlight properties. - command('hi NewHighlight gui=underline,bold,italic,reverse,strikethrough,nocombine') + command('hi NewHighlight gui=underline,bold,italic,reverse,strikethrough,altfont,nocombine') eq(expected_rgb2, nvim("get_hl_by_id", hl_id, true)) -- Test undercurl @@ -215,10 +216,12 @@ describe("API: set highlight", function() reverse = true, underline = true, strikethrough = true, + altfont = true, cterm = { italic = true, reverse = true, strikethrough = true, + altfont = true, nocombine = true, } } @@ -230,6 +233,7 @@ describe("API: set highlight", function() reverse = true, underline = true, strikethrough = true, + altfont = true, } local highlight3_result_cterm = { background = highlight_color.ctermbg, @@ -237,6 +241,7 @@ describe("API: set highlight", function() italic = true, reverse = true, strikethrough = true, + altfont = true, nocombine = true, } @@ -292,7 +297,7 @@ describe("API: set highlight", function() exec_capture('highlight Test_hl')) meths.set_hl(0, 'Test_hl2', highlight3_config) - eq('Test_hl2 xxx cterm=italic,reverse,strikethrough,nocombine ctermfg=8 ctermbg=15 gui=bold,underline,italic,reverse,strikethrough guifg=#ff0000 guibg=#0032aa', + eq('Test_hl2 xxx cterm=italic,reverse,strikethrough,altfont,nocombine ctermfg=8 ctermbg=15 gui=bold,underline,italic,reverse,strikethrough,altfont guifg=#ff0000 guibg=#0032aa', exec_capture('highlight Test_hl2')) -- Colors are stored with the name they are defined, but -- cgit