Skip to content

Commit

Permalink
Fix #100
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackerpilot committed Mar 14, 2015
1 parent 0b7bc36 commit ce1c20e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/dfmt.d
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,11 @@ private:
else if ((isBlockHeader() || currentIs(tok!"version") || currentIs(tok!"debug"))
&& peekIs(tok!"(", false))
{
immutable bool shouldPushIndent = (!currentIs(tok!"version")
&& !currentIs(tok!"debug")) || astInformation.conditionalWithElseLocations
.canFindIndex(current.index) || astInformation.conditionalStatementLocations.canFindIndex(
current.index);
immutable bool a = !currentIs(tok!"version") && !currentIs(tok!"debug") ;
immutable bool b = a || astInformation.conditionalWithElseLocations
.canFindIndex(current.index);
immutable bool shouldPushIndent = b || astInformation.conditionalStatementLocations
.canFindIndex(current.index);
if (shouldPushIndent)
indents.push(current.type);
writeToken();
Expand Down Expand Up @@ -1764,7 +1765,7 @@ struct IndentStack
foreach (i; 1 .. j + 1)
{
if ((i + 1 <= index && !isWrapIndent(arr[i]) && isTempIndent(arr[i])
&& (!isTempIndent(arr[i + 1]))))
&& (!isTempIndent(arr[i + 1]) || arr[i + 1] == tok!"switch")))
{
continue;
}
Expand Down
14 changes: 14 additions & 0 deletions tests/issue0100.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
unittest
{
loop: while (i < tokens.length) switch (tokens[i].type)
{
case tok!"(":
parenDepth++;
i++;
break;
case tok!"{":
braceDepth++;
i++;
break;
}
}
14 changes: 14 additions & 0 deletions tests/issue0100.d.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
unittest
{
loop: while (i < tokens.length) switch (tokens[i].type)
{
case tok!"(":
parenDepth++;
i++;
break;
case tok!"{":
braceDepth++;
i++;
break;
}
}

0 comments on commit ce1c20e

Please sign in to comment.