Skip to content

Commit

Permalink
make sure to print new lines before lock statements (#403)
Browse files Browse the repository at this point in the history
closes #401

Co-authored-by: Lasath Fernando <[email protected]>
  • Loading branch information
belav and shocklateboy92 authored Aug 19, 2021
1 parent edca48f commit cae1e69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ClassName
{
lock (sync)
process();

lock (sync)
{
process();
Expand Down
22 changes: 7 additions & 15 deletions Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LockStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,16 @@ public static class LockStatement
{
public static Doc Print(LockStatementSyntax node)
{
var docs = new List<Doc>
{
var statement = Node.Print(node.Statement);

return Doc.Concat(
ExtraNewLines.Print(node),
Token.PrintWithSuffix(node.LockKeyword, " "),
Token.Print(node.OpenParenToken),
Node.Print(node.Expression),
Token.Print(node.CloseParenToken)
};
var statement = Node.Print(node.Statement);
if (node.Statement is BlockSyntax)
{
docs.Add(statement);
}
else
{
docs.Add(Doc.Indent(Doc.HardLine, statement));
}

return Doc.Concat(docs);
Token.Print(node.CloseParenToken),
node.Statement is BlockSyntax ? statement : Doc.Indent(Doc.HardLine, statement)
);
}
}
}

0 comments on commit cae1e69

Please sign in to comment.