From 89ddc59d19513c5c19c8f8d2ad8573890bd00eef Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 6 Jun 2024 23:27:29 +0200 Subject: [PATCH] Revert "feat(util): opts merging now supports lists extending by tagging a table with __extend = true. Use with care" This reverts commit 74fd3611f291a2506c5534109689bb7b028f0566. --- lua/lazy/core/util.lua | 14 +------------- tests/core/util_spec.lua | 12 ------------ 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua index e76f0c4..e51e670 100644 --- a/lua/lazy/core/util.lua +++ b/lua/lazy/core/util.lua @@ -387,10 +387,6 @@ local function can_merge(v) return type(v) == "table" and (vim.tbl_isempty(v) or not M.is_list(v)) end -local function can_extend(v) - return type(v) == "table" and v.__extend -end - --- Merges the values similar to vim.tbl_deep_extend with the **force** behavior, --- but the values can be any type, in which case they override the values on the left. --- Values will me merged in-place in the first left-most table. If you want the result to be in @@ -406,15 +402,7 @@ function M.merge(...) end for i = 2, select("#", ...) do local value = select(i, ...) - local are_t = type(ret) == "table" and type(value) == "table" - if are_t and (can_extend(ret) or can_extend(value)) then - for k, v in pairs(value) do - if k ~= "__extend" then - table.insert(ret, v) - end - end - ret.__extend = true - elseif are_t and can_merge(ret) and can_merge(value) then + if can_merge(ret) and can_merge(value) then for k, v in pairs(value) do ret[k] = M.merge(ret[k], v) end diff --git a/tests/core/util_spec.lua b/tests/core/util_spec.lua index f76f185..643304d 100644 --- a/tests/core/util_spec.lua +++ b/tests/core/util_spec.lua @@ -134,18 +134,6 @@ describe("util", function() input = { { a = 1 }, { b = 2, a = vim.NIL } }, output = { b = 2 }, }, - { - input = { { 1, 2, __extend = true }, { 3, 4 } }, - output = { 1, 2, 3, 4, __extend = true }, - }, - { - input = { { 1, 2, __extend = true }, { __extend = true, 3, 4 } }, - output = { 1, 2, 3, 4, __extend = true }, - }, - { - input = { { 1, 2 }, { 3, 4, __extend = true } }, - output = { 1, 2, 3, 4, __extend = true }, - }, } for _, test in ipairs(tests) do