Skip to content

Commit 0eea53a

Browse files
committed
Fix #225
1 parent e2d2372 commit 0eea53a

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

src/dfmt/formatter.d

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,12 @@ private:
898898
indents.push(tok!"else");
899899
newline();
900900
}
901+
else if (currentIs(tok!"{") && indents.topAre(tok!"static", tok!"if"))
902+
{
903+
indents.pop();
904+
indents.pop();
905+
indents.push(tok!"else");
906+
}
901907
}
902908

903909
void formatKeyword()

tests/allman/issue0225.d.ref

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
static if (condition)
2+
int declaration;
3+
else
4+
{
5+
}

tests/issue0225.d

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
static if (condition)
2+
int declaration;
3+
else
4+
{
5+
}

tests/otbs/issue0225.d.ref

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
static if (condition)
2+
int declaration;
3+
else {
4+
}

0 commit comments

Comments
 (0)