diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index f8d6d29..52224f6 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -898,6 +898,12 @@ private: indents.push(tok!"else"); newline(); } + else if (currentIs(tok!"{") && indents.topAre(tok!"static", tok!"if")) + { + indents.pop(); + indents.pop(); + indents.push(tok!"else"); + } } void formatKeyword() diff --git a/tests/allman/issue0225.d.ref b/tests/allman/issue0225.d.ref new file mode 100644 index 0000000..b22450e --- /dev/null +++ b/tests/allman/issue0225.d.ref @@ -0,0 +1,5 @@ +static if (condition) + int declaration; +else +{ +} diff --git a/tests/issue0225.d b/tests/issue0225.d new file mode 100644 index 0000000..c58ba56 --- /dev/null +++ b/tests/issue0225.d @@ -0,0 +1,5 @@ +static if (condition) + int declaration; +else +{ +} diff --git a/tests/otbs/issue0225.d.ref b/tests/otbs/issue0225.d.ref new file mode 100644 index 0000000..b9ee234 --- /dev/null +++ b/tests/otbs/issue0225.d.ref @@ -0,0 +1,4 @@ +static if (condition) + int declaration; +else { +}