diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 9d53775..317528e 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -284,10 +284,8 @@ private: immutable canAddNewline = currTokenLine - prevTokenEndLine < 1; if (prevTokenEndLine == currTokenLine || (t == tok!")" && peekIs(tok!"{"))) write(" "); - else if (t != tok!";" && t != tok!"}" && canAddNewline) - { + else if (canAddNewline || (peekIs(tok!"{") && t == tok!"}")) newline(); - } } writeToken(); immutable j = justAddedExtraNewline; diff --git a/tests/allman/issue0177.d.ref b/tests/allman/issue0177.d.ref new file mode 100644 index 0000000..05fae07 --- /dev/null +++ b/tests/allman/issue0177.d.ref @@ -0,0 +1,29 @@ +unittest +{ + { + } + // + { + } +} + +unittest +{ + { + } + // + + { + } +} + +unittest +{ + { + } + + // + + { + } +} diff --git a/tests/issue0177.d b/tests/issue0177.d new file mode 100644 index 0000000..876854f --- /dev/null +++ b/tests/issue0177.d @@ -0,0 +1,29 @@ +unittest +{ + { + } + // + { + } +} + +unittest +{ + { + } + // + + { + } +} + +unittest +{ + { + } + + // + + { + } +} diff --git a/tests/otbs/issue0177.d.ref b/tests/otbs/issue0177.d.ref new file mode 100644 index 0000000..c2bbe3c --- /dev/null +++ b/tests/otbs/issue0177.d.ref @@ -0,0 +1,26 @@ +unittest { + { + } + // + { + } +} + +unittest { + { + } + // + + { + } +} + +unittest { + { + } + + // + + { + } +}