Increase surrounding pair performance#3186
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 722355c4ec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (hasFilteredCapture == null) { | ||
| hasFilteredCapture = match.captures.some((capture) => | ||
| captureNameFilter.has(getNormalizedCaptureName(capture.name)), | ||
| ); | ||
| patternContainsFilteredCapture.set( | ||
| match.patternIndex, | ||
| hasFilteredCapture, |
There was a problem hiding this comment.
Recompute filtered-capture presence per match
The patternContainsFilteredCapture cache assumes a pattern either always has or never has a filtered capture, but Tree-sitter patterns can include optional captures (for example queries/r.scm and queries/ruby.scm use (string_content)? @textFragment). If the first match for a pattern omits that optional capture (eg an empty string), this code caches false for the whole patternIndex and skips all later matches from that pattern, including ones that do contain @textFragment. In getCapturesMap(..., ["textFragment", ...]) this drops valid text fragments and can make surrounding-pair logic treat delimiters inside strings/comments as structural delimiters.
Useful? React with 👍 / 👎.
No description provided.