dotnet/roslyn

FormatAsync removes whitespace outside the requested bounds

オープン

#50,129 opened on 2020/12/24

 (13 件のコメント) (0 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-IDEConcept-Continuous ImprovementIDE-Formatterhelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

Version Used: 3.8.0

Steps to Reproduce:

Consider the following code:

class C
{
    public void M()
    {
        // There is a space after the ; here, and 8 spaces on the next line.
        var i = 1; 
        
    }
}

If I make a FormatAsync call, with the bounds [109..130), I get back a text change removing both the space on the end of the var line and the spaces on the line after, with a changed span of [127..138). This span is outside the bounds of what I asked for. In practice, what this means that if I have on-type formatting turned on in vscode and I have a trailing space, FormatAsync will remove the auto-indentation added in to put my cursor, when all that was asked to be formatted was the previous line.

コントリビューターガイド