Skip to content

fix(semantic-tokens): split multiline tokens one per line#8

Merged
math3usmartins merged 1 commit into
mainfrom
0.2.x
Jun 13, 2026
Merged

fix(semantic-tokens): split multiline tokens one per line#8
math3usmartins merged 1 commit into
mainfrom
0.2.x

Conversation

@math3usmartins

Copy link
Copy Markdown
Member

The LSP spec requires that semantic tokens do not span line boundaries. Block comments (/* / and /* */) were emitted as a single token covering the full text length, so clients clamped the token to the first line and left continuation lines un-highlighted.

Introduce AstVisitor::emitSplitting() which detects newlines in the raw token text and delegates to emit() once per physical line with a line-scoped length. Single-line tokens take the existing fast path unchanged. Handles \r\n line endings by stripping the trailing \r before computing each line's length.

Add unit tests asserting per-line coverage and the general no-token-spans- multiple-lines invariant, plus a Behat scenario that exercises the fix end-to-end through the live LSP server.

The LSP spec requires that semantic tokens do not span line boundaries.
Block comments (/* */ and /** */) were emitted as a single token covering
the full text length, so clients clamped the token to the first line and
left continuation lines un-highlighted.

Introduce AstVisitor::emitSplitting() which detects newlines in the raw
token text and delegates to emit() once per physical line with a
line-scoped length. Single-line tokens take the existing fast path
unchanged. Handles \r\n line endings by stripping the trailing \r before
computing each line's length.

Add unit tests asserting per-line coverage and the general no-token-spans-
multiple-lines invariant, plus a Behat scenario that exercises the fix
end-to-end through the live LSP server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@math3usmartins math3usmartins requested a review from a team June 13, 2026 08:41
@math3usmartins math3usmartins merged commit e696dac into main Jun 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant