aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/vim_spec.lua
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2024-09-08 18:23:46 +0200
committerChristian Clason <c.clason@uni-graz.at>2024-09-08 21:06:13 +0200
commit3a881132460430d23f2fdc87822c87d47f721cfc (patch)
treede8abf80bbea46c7400cde8e84a828e127b312e0 /test/functional/lua/vim_spec.lua
parent08153ddd1c149c867948f4681846531d53ba7759 (diff)
downloadrneovim-3a881132460430d23f2fdc87822c87d47f721cfc.tar.gz
rneovim-3a881132460430d23f2fdc87822c87d47f721cfc.tar.bz2
rneovim-3a881132460430d23f2fdc87822c87d47f721cfc.zip
fix(lua): revert vim.tbl_extend behavior change and document it
Problem: vim.tbl_deep_extend had an undocumented feature where arrays (integer-indexed tables) were not merged but compared literally (used for merging default and user config, where one list should overwrite the other completely). Turns out this behavior was relied on in quite a number of plugins (even though it wasn't a robust solution even for that use case, since lists of tables (e.g., plugin specs) can be array-like as well). Solution: Revert the removal of this special feature. Check for list-like (contiguous integer indices) instead, as this is closer to the intent. Document this behavior.
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r--test/functional/lua/vim_spec.lua7
1 files changed, 3 insertions, 4 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 7f10dcd8da..599b688bf4 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -1071,12 +1071,11 @@ describe('lua stdlib', function()
]])
)
- -- Fix github issue #23654
ok(exec_lua([[
- local a = { sub = { [1] = 'a' } }
- local b = { sub = { b = 'a' } }
+ local a = { sub = { 'a', 'b' } }
+ local b = { sub = { 'b', 'c' } }
local c = vim.tbl_deep_extend('force', a, b)
- return vim.deep_equal(c, { sub = { [1] = 'a', b = 'a' } })
+ return vim.deep_equal(c, { sub = { 'b', 'c' } })
]]))
matches('invalid "behavior": nil', pcall_err(exec_lua, [[return vim.tbl_deep_extend()]]))