Open kieran-ryan opened 6 months ago
Nice feature, but I think you have the wrong approach with sorting the data.
As part of the walk step, you already have the absolute line number in makeLocationToken
, which then gets converted to relative, to be pushed onto the array. Now you convert it back to absolute again, then back to relative.
It's like hokeypokey, back and forth. Maybe it's fine, but I worry that the performance can be better.
walkGherkinDocument
already supports a custom accumulation type - it doesn't have to be number[]
. I think it would be clearer to build a different kind of accumulation, then finalize that into the number[]
at the end
I'll try to come up with something to show what I mean
Edit: PR for refactor: https://github.com/cucumber/language-service/pull/220
🤔 What's changed?
#
)The Language Server Protocol semantic tokens specification accepts non-negative integers for relative text positions by default. As the gherkin-util's document walker processes table rows before comments, comments can have negative relative positions and break syntax highlighting of some tokens. As such, post-processing has been introduced to correct relative positions to always be positive.
Before
After
⚡️ What's your motivation?
Match common syntax highlighting for gherkin (such as the Cucumber docs - see below)
🏷️ What kind of change is this?
📋 Checklist: