Skip to content

Commit

Permalink
Add an explicit newline so that the formatting engine will place bloc…
Browse files Browse the repository at this point in the history
…k over multiple lines.
  • Loading branch information
CyrusNajmabadi committed Feb 15, 2018
1 parent ca55b5e commit 08c6c59
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ private Document IntroduceLocalDeclarationIntoLambda(
? SyntaxFactory.Block(declarationStatement)
: SyntaxFactory.Block(declarationStatement, SyntaxFactory.ReturnStatement(rewrittenBody));

newBody = newBody.WithAdditionalAnnotations(Formatter.Annotation);
// Add an elastic newline so that the formatter will place this new lambda body across multiple lines.
newBody = newBody.WithOpenBraceToken(newBody.OpenBraceToken.WithAppendedTrailingTrivia(SyntaxFactory.ElasticCarriageReturnLineFeed))
.WithAdditionalAnnotations(Formatter.Annotation);

var newLambda = oldLambda is ParenthesizedLambdaExpressionSyntax
? ((ParenthesizedLambdaExpressionSyntax)oldLambda).WithBody(newBody)
Expand Down

0 comments on commit 08c6c59

Please sign in to comment.