From 0ae8eccc2fb6c4be2b3928ea8965d39fdeb6f75b Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Tue, 10 Mar 2015 03:08:06 -0700 Subject: [PATCH] Fix #79 --- src/dfmt.d | 3 ++- tests/issue0079.d | 11 +++++++++++ tests/issue0079.d.ref | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/issue0079.d create mode 100644 tests/issue0079.d.ref diff --git a/src/dfmt.d b/src/dfmt.d index 86d314e..6e75f01 100644 --- a/src/dfmt.d +++ b/src/dfmt.d @@ -438,7 +438,8 @@ private: { indentLevel++; writeToken(); - newline(); + if (!currentIs(tok!"{")) + newline(); } else if (peekBackIs(tok!"identifier") && (index <= 1 || peekBack2Is(tok!"{", true) || peekBack2Is(tok!"}", true) diff --git a/tests/issue0079.d b/tests/issue0079.d new file mode 100644 index 0000000..550d871 --- /dev/null +++ b/tests/issue0079.d @@ -0,0 +1,11 @@ +unittest +{ + switch (x) + { + case a: + { + } + case b: + return; + } +} diff --git a/tests/issue0079.d.ref b/tests/issue0079.d.ref new file mode 100644 index 0000000..ebeec6e --- /dev/null +++ b/tests/issue0079.d.ref @@ -0,0 +1,11 @@ +unittest +{ + switch (x) + { + case a: + { + } + case b: + return; + } +}