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/vim_spec.lua | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'test/functional/api/vim_spec.lua') 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/vim_spec.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'test/functional/api/vim_spec.lua') 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/vim_spec.lua') 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 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/vim_spec.lua') 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/vim_spec.lua') 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/vim_spec.lua') 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 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/vim_spec.lua') 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/vim_spec.lua') 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 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/vim_spec.lua') 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 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/vim_spec.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/functional/api/vim_spec.lua') 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/vim_spec.lua') 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/vim_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/api/vim_spec.lua') 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 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/vim_spec.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'test/functional/api/vim_spec.lua') 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/vim_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/api/vim_spec.lua') 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 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/vim_spec.lua') 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/vim_spec.lua') 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/vim_spec.lua') 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