Fix #286 - Weird indentation in else branch after wrapping expression (#393)

Fix #286 - Weird indentation in else branch after wrapping expression
merged-on-behalf-of: BBasile <BBasile@users.noreply.github.com>
This commit is contained in:
Laurent Tréguier 2018-10-07 19:56:08 +02:00 committed by The Dlang Bot
parent 886903f8ea
commit 16c3811261
4 changed files with 48 additions and 2 deletions

View file

@ -730,6 +730,7 @@ private:
else
{
writeToken();
indents.popWrapIndents();
linebreakHints = [];
while (indents.topIs(tok!"enum"))
indents.pop();
@ -1313,7 +1314,8 @@ private:
{
if (isWrapToken)
{
pushWrapIndent();
if (!indents.topIs(tok!"enum"))
pushWrapIndent();
write(" ");
writeToken();
newline();
@ -1330,7 +1332,8 @@ private:
{
if (isWrapToken)
{
pushWrapIndent();
if (!indents.topIs(tok!"enum"))
pushWrapIndent();
newline();
writeToken();
}

View file

@ -0,0 +1,16 @@
void foo()
{
if (true)
enum vectorizeable = aLongExpressionThatCausesWrapping()
&& aLongExpressionThatCausesWrapping();
else
enum vectorizeable = false;
if (true)
{
enum vectorizeable = aLongExpressionThatCausesWrapping()
&& aLongExpressionThatCausesWrapping();
}
else
enum vectorizeable = false;
}

14
tests/issue0286.d Normal file
View file

@ -0,0 +1,14 @@
void foo()
{
if (true)
enum vectorizeable = aLongExpressionThatCausesWrapping()
&& aLongExpressionThatCausesWrapping();
else
enum vectorizeable = false;
if (true){
enum vectorizeable = aLongExpressionThatCausesWrapping()
&& aLongExpressionThatCausesWrapping();}
else
enum vectorizeable = false;
}

View file

@ -0,0 +1,13 @@
void foo() {
if (true)
enum vectorizeable = aLongExpressionThatCausesWrapping()
&& aLongExpressionThatCausesWrapping();
else
enum vectorizeable = false;
if (true) {
enum vectorizeable = aLongExpressionThatCausesWrapping()
&& aLongExpressionThatCausesWrapping();
} else
enum vectorizeable = false;
}