aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/func/_memoize.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-03-25 22:06:31 +0000
committerLewis Russell <me@lewisr.dev>2024-03-27 10:39:46 +0000
commit7d971500847089ec8ade926a7f84d6bb3a51c8b0 (patch)
treee626dbcfb7aaa1749a7819c00990abc8e0fc9a99 /runtime/lua/vim/func/_memoize.lua
parentc4e19308513508dca0d5f2c7786cb1e2d90f7d0b (diff)
downloadrneovim-7d971500847089ec8ade926a7f84d6bb3a51c8b0.tar.gz
rneovim-7d971500847089ec8ade926a7f84d6bb3a51c8b0.tar.bz2
rneovim-7d971500847089ec8ade926a7f84d6bb3a51c8b0.zip
fix(treesitter): return correct match table in iter_captures()
Diffstat (limited to 'runtime/lua/vim/func/_memoize.lua')
-rw-r--r--runtime/lua/vim/func/_memoize.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/lua/vim/func/_memoize.lua b/runtime/lua/vim/func/_memoize.lua
index 835bf64c93..65210351bf 100644
--- a/runtime/lua/vim/func/_memoize.lua
+++ b/runtime/lua/vim/func/_memoize.lua
@@ -36,15 +36,19 @@ end
--- @generic F: function
--- @param hash integer|string|fun(...): any
--- @param fn F
+--- @param strong? boolean
--- @return F
-return function(hash, fn)
+return function(hash, fn, strong)
vim.validate({
hash = { hash, { 'number', 'string', 'function' } },
fn = { fn, 'function' },
})
---@type table<any,table<any,any>>
- local cache = setmetatable({}, { __mode = 'kv' })
+ local cache = {}
+ if not strong then
+ setmetatable(cache, { __mode = 'kv' })
+ end
hash = resolve_hash(hash)