dotnet/roslyn

FormatAsync removes whitespace outside the requested bounds

开放

#50,129 创建于 2020年12月24日

 (13 条评论) (0 个反应) (0 位负责人)C# (4,257 个派生)batch import
Area-IDEConcept-Continuous ImprovementIDE-Formatterhelp wanted

仓库指标

星标
 (20,414 个星标)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

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.

贡献者指南