feat(util): Util.merge now support advanced merging strategies. Docs coming soon

This commit is contained in:
Folke Lemaitre 2023-01-10 07:32:28 +01:00
parent e6ee0fa610
commit b28c6b9000
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
4 changed files with 79 additions and 14 deletions

View file

@ -270,20 +270,10 @@ function Spec:merge(old, new)
for _, prop in ipairs(list_merge) do
if new[prop] and old[prop] then
---@type any[]
local props = {}
---@diagnostic disable-next-line: no-unknown
for _, value in ipairs(old[prop]) do
props[#props + 1] = value
if new[prop].__merge == nil then
new[prop].__merge = true
end
---@diagnostic disable-next-line: no-unknown
for _, value in ipairs(new[prop]) do
if not vim.tbl_contains(props, value) then
props[#props + 1] = value
end
end
---@diagnostic disable-next-line: no-unknown
new[prop] = props
new[prop] = Util.merge(old[prop], new[prop])
end
end
new._.super = old