microsoft / microsoft/language-server-protocol

Clarify whether semantic tokens can include line endings in tokens

Open
#1,170 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

clarification semantic tokens
Dominant language
TypeScript
Stars
13k
Forks
1k
Avg merge
6d 1h
Merged PRs (30d)
10

Description

It's currently not clear from the spec whether a single-line semantic token is allowed to include the line ending in tokens.

I've tested this in VS Code and it seems to work fine, but I think it should be explicit. I'm somewhat hoping that this is allowed, because my parser can produce multiline tokens that need to be split up (only for the purposes of the LSP semantic tokens), and having to "carve out" the line endings is an additional complication. It also removes the ability for a client to infer that the whole range is the same token - should it wish to - rather than two tokens.

For example, given the code:

/**
 * foo
 * foo
 */

I am currently producing comment tokens with the contents:

  • "/**\n"
  • " * foo\n"
  • " * foo\n"
  • " */"

If this seems reasonable, I propose (and can send a PR) to add something like this to the spec:

The client capability multilineTokenSupport indicates whether a client supports multiline tokens. If not, tokens lengths may include the newline characters at the end of a line but should not be longer.

Or

The client capability multilineTokenSupport indicates whether a client supports multiline tokens. If not, tokens are assumed to be truncated at the end of the line even if the server indicates the length is longer.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the semantic tokens specification and the six-comment issue thread, focusing on whether single-line token lengths may include line endings and how multilineTokenSupport affects that rule. Done means the specification states an unambiguous rule covering the examples in the issue and the proposed client behavior.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.