dotnet / dotnet/roslyn

Format document doesn't abide by existing newlines in active file

Open
#78,277 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

IDE-Formatter
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

Repro:

  1. Create new C# console app in VS
  2. Below editor scrollbar, set current newline settings in file to LF
  3. Inside main, add the following line indented improperly
    var a = "test";
  4. Format document

Expected:
Line settings to remain LF

Actual:
Line settings changed to mixed

Image before format doc:
Image

Image after format doc:
Image

Contributor guide

Open the contributing guide

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 reproducing the issue in a C# console app in Visual Studio, using the LF file setting and the indented line described in the report. Trace the Format Document behavior for the active file's newline setting; done means formatting preserves LF rather than changing the setting to mixed.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
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.