aboutsummaryrefslogtreecommitdiff
path: root/test/functional/treesitter/query_spec.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2024-09-01 13:01:53 -0500
committerGitHub <noreply@github.com>2024-09-01 18:01:53 +0000
commit6913c5e1d975a11262d08b3339d50b579e6b6bb8 (patch)
treee69809ec7eb0c7cb14b505eaf56f9de19b02a349 /test/functional/treesitter/query_spec.lua
parent318c0415d5b10b44fee4afa06994734f1beb7e71 (diff)
downloadrneovim-6913c5e1d975a11262d08b3339d50b579e6b6bb8.tar.gz
rneovim-6913c5e1d975a11262d08b3339d50b579e6b6bb8.tar.bz2
rneovim-6913c5e1d975a11262d08b3339d50b579e6b6bb8.zip
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.
Diffstat (limited to 'test/functional/treesitter/query_spec.lua')
-rw-r--r--test/functional/treesitter/query_spec.lua20
1 files changed, 8 insertions, 12 deletions
diff --git a/test/functional/treesitter/query_spec.lua b/test/functional/treesitter/query_spec.lua
index 00e8071738..d8338c1335 100644
--- a/test/functional/treesitter/query_spec.lua
+++ b/test/functional/treesitter/query_spec.lua
@@ -138,7 +138,7 @@ void ui_refresh(void)
local parser = vim.treesitter.get_parser(0, 'c')
local tree = parser:parse()[1]
local res = {}
- for pattern, match in cquery:iter_matches(tree:root(), 0, 7, 14, { all = true }) do
+ for pattern, match in cquery:iter_matches(tree:root(), 0, 7, 14) do
-- can't transmit node over RPC. just check the name and range
local mrepr = {}
for cid, nodes in pairs(match) do
@@ -211,7 +211,7 @@ void ui_refresh(void)
local parser = vim.treesitter.get_parser(0, 'c')
local tree = parser:parse()[1]
local res = {}
- for pattern, match in cquery:iter_matches(tree:root(), 0, 7, 14, { all = true }) do
+ for pattern, match in cquery:iter_matches(tree:root(), 0, 7, 14) do
-- can't transmit node over RPC. just check the name and range
local mrepr = {}
for cid, nodes in pairs(match) do
@@ -260,7 +260,7 @@ void ui_refresh(void)
local parser = vim.treesitter.get_parser(0, 'c')
local tree = parser:parse()[1]
local res = {}
- for pattern, match in cquery:iter_matches(tree:root(), 0, 7, 14, { all = true }) do
+ for pattern, match in cquery:iter_matches(tree:root(), 0, 7, 14) do
-- can't transmit node over RPC. just check the name and range
local mrepr = {}
for cid, nodes in pairs(match) do
@@ -307,7 +307,7 @@ void ui_refresh(void)
local parser = vim.treesitter.get_parser(0, 'c')
local tree = parser:parse()[1]
local res = {}
- for pattern, match in cquery:iter_matches(tree:root(), 0, 0, -1, { all = true }) do
+ for pattern, match in cquery:iter_matches(tree:root(), 0, 0, -1) do
-- can't transmit node over RPC. just check the name and range
local mrepr = {}
for cid, nodes in pairs(match) do
@@ -418,7 +418,7 @@ void ui_refresh(void)
local parser = vim.treesitter.get_parser(0, 'c')
local tree = parser:parse()[1]
local res = {}
- for pattern, match in cquery:iter_matches(tree:root(), 0, 0, -1, { all = true }) do
+ for pattern, match in cquery:iter_matches(tree:root(), 0, 0, -1) do
-- can't transmit node over RPC. just check the name and range
local mrepr = {}
for cid, nodes in pairs(match) do
@@ -464,11 +464,7 @@ void ui_refresh(void)
local parser = vim.treesitter.get_parser(0, 'c')
- -- Time bomb: update this in 0.12
- if vim.fn.has('nvim-0.12') == 1 then
- return 'Update this test to remove this message and { all = true } from add_predicate'
- end
- query.add_predicate('is-main?', is_main, { all = true })
+ query.add_predicate('is-main?', is_main)
local query0 = query.parse('c', custom_query0)
@@ -496,7 +492,7 @@ void ui_refresh(void)
local parser = vim.treesitter.get_parser(0, 'c')
- query.add_predicate('is-main?', is_main, true)
+ query.add_predicate('is-main?', is_main, { all = false, force = true })
local query0 = query.parse('c', custom_query0)
@@ -650,7 +646,7 @@ void ui_refresh(void)
local parser = vim.treesitter.get_parser(0, 'c')
local tree = parser:parse()[1]
local res = {}
- for pattern, match in cquery:iter_matches(tree:root(), 0, 7, 14) do
+ for pattern, match in cquery:iter_matches(tree:root(), 0, 7, 14, { all = false }) do
local mrepr = {}
for cid, node in pairs(match) do
table.insert(mrepr, { '@' .. cquery.captures[cid], node:type(), node:range() })