Fix #897
This commit is contained in:
@@ -74,42 +74,38 @@ misc.none = vim.NIL
|
||||
|
||||
---Merge two tables recursively
|
||||
---@generic T
|
||||
---@param v1 T
|
||||
---@param v2 T
|
||||
---@param tbl1 T
|
||||
---@param tbl2 T
|
||||
---@return T
|
||||
misc.merge = function(v1, v2)
|
||||
local merge1 = type(v1) == 'table' and (not vim.tbl_islist(v1) or vim.tbl_isempty(v1))
|
||||
local merge2 = type(v2) == 'table' and (not vim.tbl_islist(v2) or vim.tbl_isempty(v2))
|
||||
if merge1 and merge2 then
|
||||
misc.merge = function(tbl1, tbl2)
|
||||
local is_dict1 = type(tbl1) == 'table' and (not vim.tbl_islist(tbl1) or vim.tbl_isempty(tbl1))
|
||||
local is_dict2 = type(tbl2) == 'table' and (not vim.tbl_islist(tbl2) or vim.tbl_isempty(tbl2))
|
||||
if is_dict1 and is_dict2 then
|
||||
local new_tbl = {}
|
||||
for k, v in pairs(v2) do
|
||||
new_tbl[k] = misc.merge(v1[k], v)
|
||||
for k, v in pairs(tbl2) do
|
||||
if tbl1[k] ~= misc.none then
|
||||
new_tbl[k] = misc.merge(tbl1[k], v)
|
||||
end
|
||||
for k, v in pairs(v1) do
|
||||
if v2[k] == nil and v ~= misc.none then
|
||||
end
|
||||
for k, v in pairs(tbl1) do
|
||||
if tbl2[k] == nil then
|
||||
if v ~= misc.none then
|
||||
new_tbl[k] = v
|
||||
else
|
||||
new_tbl[k] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
return new_tbl
|
||||
end
|
||||
if v1 == misc.none then
|
||||
return nil
|
||||
end
|
||||
if v1 == nil then
|
||||
if v2 == misc.none then
|
||||
return nil
|
||||
else
|
||||
return v2
|
||||
end
|
||||
end
|
||||
if v1 == true then
|
||||
if merge2 then
|
||||
return v2
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
return v1
|
||||
if tbl1 == misc.none then
|
||||
return nil
|
||||
elseif tbl1 == nil then
|
||||
return misc.merge(tbl2, {})
|
||||
else
|
||||
return tbl1
|
||||
end
|
||||
end
|
||||
|
||||
---Generate id for group name
|
||||
|
||||
Reference in New Issue
Block a user