Skip to content

Fix formatting on closing brace of property pattern#36082

Merged
jcouv merged 2 commits intodotnet:masterfrom
jcouv:format-pattern
Jun 1, 2019
Merged

Fix formatting on closing brace of property pattern#36082
jcouv merged 2 commits intodotnet:masterfrom
jcouv:format-pattern

Conversation

@jcouv
Copy link
Copy Markdown
Member

@jcouv jcouv commented May 31, 2019

Fixes #34683

Previously, we didn't treat the closing brace of a property pattern as belonging to an expression, so we'd insert a newline after it in a number of cases.

// { * or } *
switch (previousToken.Kind())
{
case SyntaxKind.CloseBraceToken:
if (previousToken.IsInterpolation())
{
return null;
}
if (!previousToken.IsCloseBraceOfExpression())
{
if (!currentToken.IsKind(SyntaxKind.SemicolonToken) &&
!currentToken.IsParenInParenthesizedExpression() &&
!currentToken.IsCommaInInitializerExpression() &&
!currentToken.IsCommaInAnyArgumentsList() &&
!currentToken.IsCommaInTupleExpression() &&
!currentToken.IsParenInArgumentList() &&
!currentToken.IsDotInMemberAccess() &&
!currentToken.IsCloseParenInStatement() &&
!currentToken.IsEqualsTokenInAutoPropertyInitializers() &&
!currentToken.IsColonInCasePatternSwitchLabel() && // no newline required before colon in pattern-switch-label (ex: `case {<pattern>}:`)
!currentToken.IsColonInSwitchExpressionArm()) // no newline required before colon in switch-expression-arm (ex: `{<pattern>}: expression`)
{
return CreateAdjustNewLinesOperation(1, AdjustNewLinesOption.PreserveLines);
}
}

@jcouv jcouv added the Area-IDE label May 31, 2019
@jcouv jcouv added this to the 16.2.P3 milestone May 31, 2019
@jcouv jcouv requested a review from a team as a code owner May 31, 2019 06:19
@jcouv jcouv self-assigned this May 31, 2019
@jcouv jcouv closed this May 31, 2019
@jcouv jcouv reopened this May 31, 2019
@jcouv jcouv merged commit 910a333 into dotnet:master Jun 1, 2019
@jcouv jcouv deleted the format-pattern branch June 1, 2019 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatting x is {} && y introduces a newline

2 participants