Add range check to highlightsFromCursor
#187
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes a bug found found by @cengelbart39 on discord where a parser would consume ranges already consumed by injected languages. This caused the injected ranges to be realized as plain text, when they should have been kept as their injected language's highlights.
This should have been avoided by the call to
query.setRange(range)
on line 43 in TreeSitterClient+Highlight.swift but it was found that for some reason in the case found by @cengelbart39 it just didn't work.To fix, an additional check was added in
highlightsFromCursor
to only take any ranges that have indices in the intersection of it's range and the included range.Related Issues
Checklist
Screenshots
Before:
Screen_Recording_2023-05-04_at_11.00.00_AM.mov
After:
Screen.Recording.2023-05-07.at.2.04.46.PM.mov