Skip to content

highlighter: Add a QueryMatchIter type - #39

Merged
the-mikedavis merged 1 commit into
masterfrom
match-iter
May 30, 2026
Merged

the-mikedavis merged 1 commit into
masterfrom
match-iter

Conversation

@the-mikedavis

Copy link
Copy Markdown
Member

This adds a new iterator type, very similar to QueryIter, called QueryMatchIter. There's a new trait covering the peeking strategy so that we can share the layer management code between the two. QueryIter is an iterator across injection layers of captures while the new QueryMatchIter returns entire matches. Tree-sitter supports iterating on either - we needed some extra work in the highlighter crate here to expose that same choice across injection layers.

This is more useful for some tree-sitter use-cases. Specifically what I have in mind is for tags.scm queries we want to associate the @name capture in a match with the @definition.* capture. A query match does that automatically for us, while with query captures we'd need to maintain extra state tracking the captures in a match.

Also see helix-editor/helix#14853, #29, cc @m4rch3n1ng. A sample usage of this is in helix-editor/helix@cefee4e.

@the-mikedavis
the-mikedavis requested a review from pascalkuthe May 30, 2026 14:32
@the-mikedavis the-mikedavis self-assigned this May 30, 2026
@m4rch3n1ng

Copy link
Copy Markdown

this looks good, is there anything i should do / do you want me to close my other prs?

@the-mikedavis

Copy link
Copy Markdown
Member Author

I'll swing through the PRs and close them out once this is all merged down, I just wanted to mention what I was thinking for this problem.

@the-mikedavis
the-mikedavis merged commit 85e8877 into master May 30, 2026
4 checks passed
@the-mikedavis
the-mikedavis deleted the match-iter branch May 30, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants