Skip to content

Commit

Permalink
Start of better indent for lamda
Browse files Browse the repository at this point in the history
closes #669
  • Loading branch information
belav committed May 21, 2022
1 parent 0e833f8 commit b0288ad
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion Src/CSharpier/SyntaxPrinter/ArgumentListLikeSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,60 @@ public static Doc Print(
FormattingContext context
)
{
/*
prettier has a lot more logic around printing arguments, we could stick to just making () => better for now
but it would be nice to get o => better as well, but that leads to more edge cases
CallMethod(() =>
{
CallOtherMethod();
});
CallMethod(
(
longParameter_____________________________,
longParameter_____________________________,
longParameter_____________________________
) =>
{
CallOtherMethod();
}
);
// this looks bad
var y = someList.Where(o =>
someLongValue_______________________
&& theseShouldNotIndent_________________
&& theseShouldNotIndent_________________
> butThisOneShould_________________________________________);
var y = someList.Where(o =>
{
return someLongValue_______________________
&& theseShouldNotIndent_________________
&& theseShouldNotIndent_________________
> butThisOneShould_________________________________________;
});
*/

var docs = new List<Doc> { Token.Print(openParenToken, context) };

if (arguments.Any())
if (
arguments.Count == 1
&& arguments[0].Expression
is ParenthesizedLambdaExpressionSyntax
{
ParameterList: { Parameters: { Count: 0 } }
}
// TODO
// or SimpleLambdaExpressionSyntax
)
{
docs.Add(Argument.Print(arguments[0], context));
}
else if (arguments.Any())
{
docs.Add(
Doc.Indent(
Expand Down

0 comments on commit b0288ad

Please sign in to comment.