Skip to content

LSP: Extra newlines are inserted when requesting "crlf" in a document with pre-existing unix line endings #314

@DavisVaughan

Description

@DavisVaughan
  • Open a Unix line ending R file
  • Set line-ending = "crlf" in an air.toml
  • Save using the LSP
Screen.Recording.2025-04-18.at.1.20.56.PM.mov

I think this line is relevant?

// TODO: Handle user requested line ending preference here

I'm not 100% sure what is going on:

  • Client opens unix document. Document::new() sets LineIndex's endings to LineEnding::Lf
  • Formatting occurs on save. Formatter uses air.toml option and generates a formatted string output with Crlf endings (\r\n)
  • replace_all_edit() is called using the original line index and its original stored options, i.e. endings of Lf! A bunch of Indels are generated, with insertions of \r because that is the only difference. It does seem like we keep the \r all the way through this function and send it back to the frontend?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions