zls icon indicating copy to clipboard operation
zls copied to clipboard

Fix fallback logic in `analysis.getPositionContext`

Open llogick opened this issue 2 years ago • 3 comments

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 .

llogick avatar Feb 09 '24 18:02 llogick

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.

codecov[bot] avatar Feb 09 '24 18:02 codecov[bot]

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).

llogick avatar Feb 11 '24 07:02 llogick

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).

llogick avatar Apr 13 '24 22:04 llogick