diff --git a/src/dfmt.d b/src/dfmt.d index 1c37f65..df9a8df 100644 --- a/src/dfmt.d +++ b/src/dfmt.d @@ -660,16 +660,14 @@ private: } else { - if (config.braceStyle == BraceStyle.otbs) + if (index > 0 && !justAddedExtraNewline && !peekBackIs(tok!"{") && !peekBackIs(tok!"}")) { - write(" "); - write("{"); - } - else - { - newline(); - write("{"); + if (config.braceStyle == BraceStyle.otbs) + write(" "); + else + newline(); } + write("{"); indentLevel++; index++; newline(); diff --git a/tests/issue0056.d b/tests/issue0056.d new file mode 100644 index 0000000..acfe8a0 --- /dev/null +++ b/tests/issue0056.d @@ -0,0 +1 @@ +{{{}}{}} diff --git a/tests/issue0056.d.ref b/tests/issue0056.d.ref new file mode 100644 index 0000000..bb0c65e --- /dev/null +++ b/tests/issue0056.d.ref @@ -0,0 +1,8 @@ +{ + { + { + } + } + { + } +}