Closed YikeZhou closed 4 months ago
I think that's intended, just not properly documented.
captures
returns all the captured nodes while matches
returns the last one.
Thanks for the quick reply! I just ran tree-sitter query
with the --captures
option (which I failed to notice before). Its result was the same with Query.captures()
.
What does "the last [node]" mean?
Hello, recently I noticed an inconsistency in the results I got from
Query.captures()
and tree-sitter-cli (version:0.22.2
). Then I triedQuery.matches()
with the same source code and query, it seemed that the result given byQuery.captures()
is incorrect.While opening this issue, I noticed #208 has changed lots of APIs, including
Query.captures()
. I hope this can help detect potential defects in this API.Reproduction Steps
Here is a Python program to demonstrate the problem I observed.
And it outputs:
Run tree-sitter-cli on the same source code and query, it gives:
Version
I installed py-tree-sitter with pip on an x86-64 Linux PC.