Skip to content

Commit

Permalink
Fixing weird edge that involved initializers + invocations on them.
Browse files Browse the repository at this point in the history
closes #802
  • Loading branch information
belav committed Feb 4, 2023
1 parent c32bbfd commit b96da47
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,48 @@ class ClassName
? one
: two
};

var someObject = new SomeObject
{
SomeArray = new SomeOtherObject[]
{
new SomeOtherObject { SomeProperty = 1 },
new SomeOtherObject()
}
.CallMethod()
.CallMethod()
};

var someObject = new SomeObject
{
SomeArray = new SomeOtherObject
{
new SomeOtherObject { SomeProperty = 1 },
new SomeOtherObject()
}
.CallMethod()
.CallMethod()
};

var someObject = new SomeObject
{
SomeArray = new SomeOtherObject[]
{
new SomeOtherObject { SomeProperty = 1 },
new SomeOtherObject()
}
};

var someObject = new SomeObject
{
SomeArray = new SomeOtherObject[]
{
new SomeOtherObject_________________________________(),
new SomeOtherObject_________________________________()
}
.CallMethod()
.CallMethod()
};
}

private SomeObject someObject =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ or PostfixUnaryExpressionSyntax
PrintIndentedGroup(node, groups.Skip(shouldMergeFirstTwoGroups ? 2 : 1).ToList())
);

return oneLine.Skip(1).Any(DocUtilities.ContainsBreak)
return
oneLine.Skip(1).Any(DocUtilities.ContainsBreak)
|| groups[0].Any(
o => o.Node is ArrayCreationExpressionSyntax or ObjectCreationExpressionSyntax
)
? expanded
: Doc.ConditionalGroup(Doc.Concat(oneLine), expanded);
}
Expand Down

0 comments on commit b96da47

Please sign in to comment.