Skip to content

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

Open
@DanTup

Description

@DanTup

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:

format.mp4

I filed microsoft/vscode#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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions