From 1a655b71a888a2be86ff7d1ff534eac32fc83620 Mon Sep 17 00:00:00 2001 From: JP <17429390+resolritter@users.noreply.github.com> Date: Mon, 18 Jul 2022 22:11:13 -0300 Subject: fix(lua): make it possible to cancel vim.wait() with Ctrl-C (#19217) --- test/functional/lua/vim_spec.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test/functional/lua/vim_spec.lua') diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 883e0e373b..e2347c3c11 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -2493,6 +2493,41 @@ describe('lua stdlib', function() eq(false, pcall_result) end) + + describe('returns -2 when interrupted', function() + before_each(function() + local channel = meths.get_api_info()[1] + meths.set_var('channel', channel) + end) + + it('without callback', function() + exec_lua([[ + function _G.Wait() + vim.rpcnotify(vim.g.channel, 'ready') + local _, interrupted = vim.wait(4000) + vim.rpcnotify(vim.g.channel, 'wait', interrupted) + end + ]]) + feed(':lua _G.Wait()') + eq({'notification', 'ready', {}}, next_msg(500)) + feed('') + eq({'notification', 'wait', {-2}}, next_msg(500)) + end) + + it('with callback', function() + exec_lua([[ + function _G.Wait() + vim.rpcnotify(vim.g.channel, 'ready') + local _, interrupted = vim.wait(4000, function() end) + vim.rpcnotify(vim.g.channel, 'wait', interrupted) + end + ]]) + feed(':lua _G.Wait()') + eq({'notification', 'ready', {}}, next_msg(500)) + feed('') + eq({'notification', 'wait', {-2}}, next_msg(500)) + end) + end) end) it('vim.notify_once', function() -- cgit From 559ef3e90393a8f02c8350a9d60f4b7849815d97 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 20 Jul 2022 12:29:24 +0100 Subject: feat(lua): allow vim.cmd to be indexed (#19238) --- test/functional/lua/vim_spec.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/functional/lua/vim_spec.lua') diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index e2347c3c11..57bb2f9765 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -2148,6 +2148,13 @@ describe('lua stdlib', function() ]] eq('2', funcs.luaeval "BUF") eq(2, funcs.luaeval "#vim.api.nvim_list_bufs()") + + -- vim.cmd can be indexed with a command name + exec_lua [[ + vim.cmd.let 'g:var = 2' + ]] + + eq(2, funcs.luaeval "vim.g.var") end) it('vim.regex', function() -- cgit From 0a049c322fda5f2bb124429086c2713ff99c7142 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 2 Aug 2022 11:13:22 +0800 Subject: test: improve mapping tests and docs (#19619) --- test/functional/lua/vim_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/lua/vim_spec.lua') diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 57bb2f9765..2b249b7a69 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -2792,12 +2792,12 @@ describe('vim.keymap', function() it('can make an expr mapping', function() exec_lua [[ - vim.keymap.set('n', 'aa', function() return ':lua SomeValue = 99' end, {expr = true}) + vim.keymap.set('n', 'aa', function() return 'πfoo' end, {expr = true}) ]] feed('aa') - eq(99, exec_lua[[return SomeValue]]) + eq({'πfoo<'}, meths.buf_get_lines(0, 0, -1, false)) end) it('can overwrite a mapping', function() -- cgit