Fix fallback logic in `analysis.getPositionContext`
Most lines are indented, ie line[0] == ' '(a space).
Tokenizing line as the sole buffer returns location offsets relative/within to that line, but are expected to be indexes within handle.tree.source .
Codecov Report
Attention: 1 lines in your changes are missing coverage. Please review.
Comparison is base (
6478f1a) 76.58% compared to head (b4d49a9) 76.59%.
| Files | Patch % | Lines |
|---|---|---|
| src/analysis.zig | 90.00% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #1754 +/- ##
=======================================
Coverage 76.58% 76.59%
=======================================
Files 35 35
Lines 10088 10090 +2
=======================================
+ Hits 7726 7728 +2
Misses 2362 2362
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Having done this makes me realize having that logic is very dicey and
https://github.com/zigtools/zls/blob/05ae41e3f4af684628c97a921b85e07d921f38e2/src/features/completions.zig#L1338
should just use tok_loc.end or
https://github.com/zigtools/zls/blob/05ae41e3f4af684628c97a921b85e07d921f38e2/src/features/completions.zig#L1197
look_ahead = true here (haven't tested for side effects).
This is a low priority PR, the test changes are worth having, but in my opinion the fallback logic shouldn't exist (and obviously nothing depends on it currently).