mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
lua: if second argument is vim.empty_dict(), vim.tbl_extend uses empty_dict() instead of {}
This commit is contained in:
parent
417fc6ccf7
commit
c230c7d1a6
@ -21,7 +21,7 @@ vim.deepcopy = (function()
|
|||||||
table = function(orig)
|
table = function(orig)
|
||||||
local copy = {}
|
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()
|
copy = vim.empty_dict()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -174,9 +174,19 @@ function vim.tbl_extend(behavior, ...)
|
|||||||
if (behavior ~= 'error' and behavior ~= 'keep' and behavior ~= 'force') then
|
if (behavior ~= 'error' and behavior ~= 'keep' and behavior ~= 'force') then
|
||||||
error('invalid "behavior": '..tostring(behavior))
|
error('invalid "behavior": '..tostring(behavior))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if select('#', ...) < 2 then
|
||||||
|
error('wrong number of arguments (given '..tostring(1 + select('#', ...))..', expected at least 3)')
|
||||||
|
end
|
||||||
|
|
||||||
local ret = {}
|
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
|
for i = 1, select('#', ...) do
|
||||||
local tbl = select(i, ...)
|
local tbl = select(i, ...)
|
||||||
|
vim.validate{["after the second argument"] = {tbl,'t'}}
|
||||||
if tbl then
|
if tbl then
|
||||||
for k, v in pairs(tbl) do
|
for k, v in pairs(tbl) do
|
||||||
if behavior ~= 'force' and ret[k] ~= nil then
|
if behavior ~= 'force' and ret[k] ~= nil then
|
||||||
|
Loading…
Reference in New Issue
Block a user