aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/shared.lua
diff options
context:
space:
mode:
authorHirokazu Hata <h.hata.ai.t@gmail.com>2020-02-13 15:02:30 +0900
committerHirokazu Hata <h.hata.ai.t@gmail.com>2020-02-14 19:35:46 +0900
commitc230c7d1a6b744efb673f516f0c6cc2a17c2305b (patch)
tree56809e54a204f01bf44f741de247d4437d6a800c /runtime/lua/vim/shared.lua
parent417fc6ccf78801aef79a8731c5a85db6b12cd407 (diff)
downloadrneovim-c230c7d1a6b744efb673f516f0c6cc2a17c2305b.tar.gz
rneovim-c230c7d1a6b744efb673f516f0c6cc2a17c2305b.tar.bz2
rneovim-c230c7d1a6b744efb673f516f0c6cc2a17c2305b.zip
lua: if second argument is vim.empty_dict(), vim.tbl_extend uses empty_dict() instead of {}
Diffstat (limited to 'runtime/lua/vim/shared.lua')
-rw-r--r--runtime/lua/vim/shared.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 36df24d0c1..6eb7a970e4 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -21,7 +21,7 @@ vim.deepcopy = (function()
table = function(orig)
local copy = {}
- if getmetatable(orig) == vim._empty_dict_mt then
+ if vim._empty_dict_mt ~= nil and getmetatable(orig) == vim._empty_dict_mt then
copy = vim.empty_dict()
end
@@ -174,9 +174,19 @@ function vim.tbl_extend(behavior, ...)
if (behavior ~= 'error' and behavior ~= 'keep' and behavior ~= 'force') then
error('invalid "behavior": '..tostring(behavior))
end
+
+ if select('#', ...) < 2 then
+ error('wrong number of arguments (given '..tostring(1 + select('#', ...))..', expected at least 3)')
+ end
+
local ret = {}
+ if vim._empty_dict_mt ~= nil and getmetatable(select(1, ...)) == vim._empty_dict_mt then
+ ret = vim.empty_dict()
+ end
+
for i = 1, select('#', ...) do
local tbl = select(i, ...)
+ vim.validate{["after the second argument"] = {tbl,'t'}}
if tbl then
for k, v in pairs(tbl) do
if behavior ~= 'force' and ret[k] ~= nil then