aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/lua/vim/treesitter.lua5
-rw-r--r--test/functional/lua/treesitter_spec.lua2
2 files changed, 4 insertions, 3 deletions
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua
index d3b78a7f73..c502e45bd0 100644
--- a/runtime/lua/vim/treesitter.lua
+++ b/runtime/lua/vim/treesitter.lua
@@ -162,16 +162,17 @@ function Query:match_preds(match, pattern, bufnr)
-- Here we only want to return if a predicate DOES NOT match, and
-- continue on the other case. This way unknown predicates will not be considered,
-- which allows some testing and easier user extensibility (#12173).
+ -- Also, tree-sitter strips the leading # from predicates for us.
if pred[1] == "eq?" then
local node = match[pred[2]]
local node_text = get_node_text(node, bufnr)
local str
if type(pred[3]) == "string" then
- -- (eq? @aa "foo")
+ -- (#eq? @aa "foo")
str = pred[3]
else
- -- (eq? @aa @bb)
+ -- (#eq? @aa @bb)
str = get_node_text(match[pred[3]], bufnr)
end
diff --git a/test/functional/lua/treesitter_spec.lua b/test/functional/lua/treesitter_spec.lua
index cb0e46b9eb..ecee471386 100644
--- a/test/functional/lua/treesitter_spec.lua
+++ b/test/functional/lua/treesitter_spec.lua
@@ -250,7 +250,7 @@ static int nlua_schedule(lua_State *const lstate)
; still support \M etc prefixes
((identifier) @Constant (#match? @Constant "\M^\[A-Z_]\+$"))
-((binary_expression left: (identifier) @WarningMsg.left right: (identifier) @WarningMsg.right) (eq? @WarningMsg.left @WarningMsg.right))
+((binary_expression left: (identifier) @WarningMsg.left right: (identifier) @WarningMsg.right) (#eq? @WarningMsg.left @WarningMsg.right))
(comment) @comment
]]