Skip to content

Commit

Permalink
Cleaning up formatting of fors with empty statements (#528)
Browse files Browse the repository at this point in the history
closes #523
  • Loading branch information
belav authored Dec 21, 2021
1 parent 7876be6 commit 16f768e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 16 additions & 1 deletion Src/CSharpier.Tests/FormattingTests/TestFiles/ForStatements.cst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@ class ClassName
break;
}

for (;;)
for (; ; )
{
break;
}

for (var x = 1; ; )
{
break;
}

for (var x = 1; x < 0; )
{
break;
}

for (var x = 1; ; x++)
{
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public static Doc Print(ForStatementSyntax node)
),
node.Condition != null
? Doc.Concat(Doc.Line, Node.Print(node.Condition))
: Doc.SoftLine,
: Doc.Line,
Token.Print(node.SecondSemicolonToken),
node.Incrementors.Any() ? Doc.Line : Doc.SoftLine,
Doc.Line,
Doc.Group(
Doc.Indent(
SeparatedSyntaxList.Print(node.Incrementors, Node.Print, Doc.Line)
Expand Down

0 comments on commit 16f768e

Please sign in to comment.