Repository navigation
feat: support highlighting tokens by range - #331
Conversation
Codecov Report
@@ Coverage Diff @@
## master #331 +/- ##
==========================================
+ Coverage 85.64% 85.86% +0.22%
==========================================
Files 14 14
Lines 620 651 +31
Branches 158 174 +16
==========================================
+ Hits 531 559 +28
- Misses 89 92 +3
Continue to review full report at Codecov.
|
felixfbecker
left a comment
There was a problem hiding this comment.
Nice! Codecov shows there are a couple of branches in the new code never hit by tests (decreasing coverage). Are they testable?
| break | ||
| let startNode: Node | ||
| let endNode: Node | ||
| if (typeof offsetEnd === 'number' && offsetEnd > offsetStart) { |
There was a problem hiding this comment.
question: why do ranges and positions need to be handled in completely separate branches?
There was a problem hiding this comment.
There's not much overlap between these branches. When findElementWithOffset is called with a Position, we should look forwards and backwards to find all elements the token at that position is comprised of. When it's called with a Range we assume that the position boundaries are intentional (i.e. that the user either already knows the start and end positions of the token, or doesn't want to highlight a discrete token)
|
I don't see much new logic that's untested:
I'll add tests for invalid ranges. Should we also test the previously untested cases? |
felixfbecker
left a comment
There was a problem hiding this comment.
@marekweb could you review too?
|
🎉 This PR is included in version 7.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #224
Find and highlight tokens by range, not just position.
Limitations:
startandendposition must be on the same line