diff --git a/src/dfmt.d b/src/dfmt.d index c413dd4..188e2c5 100644 --- a/src/dfmt.d +++ b/src/dfmt.d @@ -839,6 +839,8 @@ private: else newline(); writeToken(); + if (!currentIs(tok!"case") && !currentIs(tok!"default") && !currentIs(tok!"}")) + indentLevel++; newline(); while (index < tokens.length) { @@ -850,7 +852,7 @@ private: newline(); return; } - else if (current.type == tok!";" && peekIs(tok!"}")) + else if (current.type == tok!";" && peekIs(tok!"}", false)) { writeToken(); newline(); @@ -886,6 +888,8 @@ private: else goto peek; } + else if (currentIs(tok!"}", false)) + break; else { peek: diff --git a/tests/issue0062.d b/tests/issue0062.d new file mode 100644 index 0000000..013133f --- /dev/null +++ b/tests/issue0062.d @@ -0,0 +1,7 @@ +unittest +{ + switch (op) + { + return -1; // memory blocks are different + } +} diff --git a/tests/issue0062.d.ref b/tests/issue0062.d.ref new file mode 100644 index 0000000..013133f --- /dev/null +++ b/tests/issue0062.d.ref @@ -0,0 +1,7 @@ +unittest +{ + switch (op) + { + return -1; // memory blocks are different + } +}