dotnet/roslyn
View on GitHubFormatAsync removes whitespace outside the requested bounds
Open
#50,129 opened on Dec 24, 2020
Area-IDEConcept-Continuous ImprovementIDE-Formatterhelp wanted
Repository metrics
- Stars
- (20,414 stars)
- PR merge metrics
- (Avg merge 6d 17h) (256 merged PRs in 30d)
Description
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.