From 7952562efc6911d1b99f6e737651cb1cb33fc597 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Sun, 8 Mar 2015 00:29:36 -0800 Subject: [PATCH] Fix #62 --- src/dfmt.d | 6 +++++- tests/issue0062.d | 7 +++++++ tests/issue0062.d.ref | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/issue0062.d create mode 100644 tests/issue0062.d.ref 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 + } +}