Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add range check to
highlightsFromCursor
(#187)
<!--- IMPORTANT: If this PR addresses multiple unrelated issues, it will be closed until separated. --> ### Description Fixes a bug found found by @cengelbart39 [on discord](https://canary.discord.com/channels/951544472238444645/952640521812193411/1104143145765187644) 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](https://github.com/CodeEditApp/CodeEditTextView/blob/045bd359ef9c4addf2a5bf51e22ba660d69c5d10/Sources/CodeEditTextView/TreeSitter/TreeSitterClient%2BHighlight.swift#L44) 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 <!--- REQUIRED: Tag all related issues (e.g. * #123) --> <!--- If this PR resolves the issue please specify (e.g. * closes #123) --> <!--- If this PR addresses multiple issues, these issues must be related to one other --> * See discord link. ### Checklist <!--- Add things that are not yet implemented above --> - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code ### Screenshots Before: https://user-images.githubusercontent.com/35942988/236696171-d30dfd7b-8545-4396-8aa8-490ceac65551.mov After: https://user-images.githubusercontent.com/35942988/236697575-3f605c0d-3dda-45c2-8f69-0f41148f1c2d.mov