Commit 521dd43
authored
Add range check to
<!--- 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.movhighlightsFromCursor (#187)1 parent b60e0fc commit 521dd43
File tree
1 file changed
+10
-5
lines changed- Sources/CodeEditTextView/TreeSitter
1 file changed
+10
-5
lines changedLines changed: 10 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | | - | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
62 | | - | |
63 | | - | |
| 67 | + | |
| 68 | + | |
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
| |||
0 commit comments