From 6913c5e1d975a11262d08b3339d50b579e6b6bb8 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Sun, 1 Sep 2024 13:01:53 -0500 Subject: feat(treesitter)!: default to correct behavior for quantified captures (#30193) For context, see https://github.com/neovim/neovim/pull/24738. Before that PR, Nvim did not correctly handle captures with quantifiers. That PR made the correct behavior opt-in to minimize breaking changes, with the intention that the correct behavior would eventually become the default. Users can still opt-in to the old (incorrect) behavior for now, but this option will eventually be removed completely. BREAKING CHANGE: Any plugin which uses `Query:iter_matches()` must update their call sites to expect an array of nodes in the `match` table, rather than a single node. --- test/functional/treesitter/parser_spec.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'test/functional/treesitter/parser_spec.lua') diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua index 46e6a6002a..4aa8beebae 100644 --- a/test/functional/treesitter/parser_spec.lua +++ b/test/functional/treesitter/parser_spec.lua @@ -591,8 +591,7 @@ print() vim.treesitter.query.parse('c', '((number_literal) @number (#set! "key" "value"))') local parser = vim.treesitter.get_parser(0, 'c') - local _, _, metadata = - query:iter_matches(parser:parse()[1]:root(), 0, 0, -1, { all = true })() + local _, _, metadata = query:iter_matches(parser:parse()[1]:root(), 0, 0, -1)() return metadata.key end) @@ -612,8 +611,7 @@ print() ) local parser = vim.treesitter.get_parser(0, 'c') - local _, _, metadata = - query:iter_matches(parser:parse()[1]:root(), 0, 0, -1, { all = true })() + local _, _, metadata = query:iter_matches(parser:parse()[1]:root(), 0, 0, -1)() local _, nested_tbl = next(metadata) return nested_tbl.key end) @@ -633,8 +631,7 @@ print() ) local parser = vim.treesitter.get_parser(0, 'c') - local _, _, metadata = - query:iter_matches(parser:parse()[1]:root(), 0, 0, -1, { all = true })() + local _, _, metadata = query:iter_matches(parser:parse()[1]:root(), 0, 0, -1)() local _, nested_tbl = next(metadata) return nested_tbl end) -- cgit