aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/vim_spec.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2023-04-01 08:02:58 -0600
committerGitHub <noreply@github.com>2023-04-01 08:02:58 -0600
commit643c0ed571f1ac6e83f73ab2593132901278b4da (patch)
treeaa37b3c75806a016f2d0b76b4691a9024bbc253c /test/functional/lua/vim_spec.lua
parent6a4ebf894fa39bfb09695a129a3300cb99408542 (diff)
downloadrneovim-643c0ed571f1ac6e83f73ab2593132901278b4da.tar.gz
rneovim-643c0ed571f1ac6e83f73ab2593132901278b4da.tar.bz2
rneovim-643c0ed571f1ac6e83f73ab2593132901278b4da.zip
feat: allow function passed to defaulttable to take an argument (#22839)
Pass the value of the key being accessed to the create function, to allow users to dynamically generate default values.
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r--test/functional/lua/vim_spec.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index a0428ed933..4f401eed8f 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -2915,6 +2915,15 @@ describe('lua stdlib', function()
return a
]])
end)
+
+ it('accepts the key name', function()
+ eq({ b = 'b', c = 'c' }, exec_lua [[
+ local a = vim.defaulttable(function(k) return k end)
+ local _ = a.b
+ local _ = a.c
+ return a
+ ]])
+ end)
end)
it('vim.lua_omnifunc', function()