feat(func): allow manual cache invalidation for _memoize

This commit also adds some tests for the existing memoization
functionality.
This commit is contained in:
Riley Bruins
2024-09-01 16:54:30 -07:00
committed by Christian Clason
parent 54ac406649
commit b61051ccb4
4 changed files with 191 additions and 25 deletions

View File

@@ -902,8 +902,8 @@ function Query:iter_captures(node, source, start, stop)
local cursor = vim._create_ts_querycursor(node, self.query, start, stop, { match_limit = 256 })
local apply_directives = memoize(match_id_hash, self.apply_directives, true)
local match_preds = memoize(match_id_hash, self.match_preds, true)
local apply_directives = memoize(match_id_hash, self.apply_directives, false)
local match_preds = memoize(match_id_hash, self.match_preds, false)
local function iter(end_line)
local capture, captured_node, match = cursor:next_capture()