-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(query): add first_retun flag to TSQueryMatch #1372
Conversation
Allows for users of the API to determine if the match is returned for the first time, for example to run the predicates only once.
ping @maxbrunsfeld is this something you would consider adding? This is needed to effectively highlight regions of a file, if only some captures of a complex match is part of the redrawn region. |
The |
I'm just remembering more about this problem... The benefit of the I think we could actually change the implementation so that the |
I pushed a small commit to |
@maxbrunsfeld yes, I think that would work for us, we will give it a try 👍 |
Seems like that commit also fixed an issue I had recently, illustrated using the HCL grammar: With this code: resource "random_pet" "this" {
length = 2
}
resource "tls_private_key" "this" {
algorithm = "RSA"
}
resource "aws_key_pair" "this" {
key_name = random_pet.this.id
public_key = tls_private_key.this.public_key_openssh
} and this query: ((block (identifier) @keyword
. [(string_lit (template_literal) @function)
(identifier) @function])
(.eq? @keyword "output"))
((block (identifier) @keyword)
(.match? @keyword "^(resource|data|output|locals|lifecycle)$")) The command
|
Hey, sorry to bother you again, but the fix pushed to master effectively fixes our issue. Thanks in advance ! |
I published Tree-sitter 0.20.1. |
Allows for users of the API to determine if the match is returned for the first time, for example to run the predicates only once.
We encountered this little problem when working on tree-sitter intergration on neovim.
cc @bfredl