Skip to content

Commit

Permalink
Improving formatting of conditional in argument list (#432)
Browse files Browse the repository at this point in the history
closes #419

Co-authored-by: Lasath Fernando <devel@lasath.org>
  • Loading branch information
belav and shocklateboy92 authored Sep 7, 2021
1 parent 3c09eb3 commit be056da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,25 @@ public class ClassName
? trueValue
: falseValue;

CallMethod(
someValue,
someCondition
? trueValue________________________________
: falseValue_______________________________,
someCondition_____________________________________
&& someOtherCondition__________________________________
? trueValue________________________________
: falseValue_______________________________,
someCondition_____________________________________
&& someOtherCondition__________________________________
);

var fileContents = File.ReadAllText(
file,
// leading here should break parameters and GetEncoding should still group
encoding
? File.GetEncoding________________________________(1252)
: encoding_____________________,
? File.GetEncoding________________________________(1252)
: encoding_____________________,
cancellationToken
);

Expand All @@ -49,13 +62,5 @@ public class ClassName
encoding ? GetEncoding(1252) : encoding,
cancellationToken
);

var fileContents = File.ReadAllText(
file,
encoding
? File.GetEncoding________________________________(1252)
: encoding_____________________,
cancellationToken
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ or EqualsValueClauseSyntax
or ArrowExpressionClauseSyntax
or ParenthesizedLambdaExpressionSyntax
or AssignmentExpressionSyntax
or ConditionalExpressionSyntax
or SimpleLambdaExpressionSyntax
or IfStatementSyntax
or WhileStatementSyntax
Expand All @@ -33,7 +32,9 @@ or DoStatementSyntax
or CheckedExpressionSyntax
or CatchFilterClauseSyntax
or ParenthesizedExpressionSyntax
or SwitchStatementSyntax;
or SwitchStatementSyntax
|| node.Parent is ConditionalExpressionSyntax
&& node.Parent.Parent is not ArgumentSyntax;

return shouldNotIndent
? Doc.Group(docs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static Doc Print(ConditionalExpressionSyntax node)

return Doc.Group(
Node.Print(node.Condition),
node.Parent is ConditionalExpressionSyntax
node.Parent is ConditionalExpressionSyntax or ArgumentSyntax
? Doc.Align(2, contents)
: Doc.Indent(contents)
);
Expand Down

0 comments on commit be056da

Please sign in to comment.