microsoft / microsoft/language-server-protocol

Specify exactly what "the client will normalize line ending characters" means

Open
#1,853 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I recently hit a weird but where our formatter was changing \n in a document to \r\n. Because we have a step to minimize edits (because otherwise things like breakpoints could be lost), the edit was reduced to "insert \r before the \n".

However, in VS Code this resulted in \n\n in the document instead of \r\n which meant a new blank line appeared between every line of code:

https://github.com/Dart-Code/Dart-Code/assets/1078012/4cbe6c12-36ae-4b86-bd0f-d846fe0936c1

I filed https://github.com/microsoft/vscode/issues/200157 but this is considered by design. IMO this is not obvious behaviour from the current spec, and for servers not to produce edits that mess up a users code, the rules need to be clear.

So, I think the comments on the WorkspaceEditClientCapabilities.normalizesLineEndings class field need to clearly describe the rules of normalisation so that clients and servers have the same expectations/behaviour.

@dbaeumer I'm happy to send a PR detailing VS Code's behaviour if you think it's reasonable to define this as the LSP behaviour.

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 reading the comments on WorkspaceEditClientCapabilities.normalizesLineEndings and the linked VS Code issue 200157 to compare the current wording with VS Code's behavior. Done means the LSP specification clearly defines the normalization rules so clients and servers have consistent expectations.

Written by the indexing model from the issue text.

Assessment

Domain
api, 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.