diff --git a/src/dfmt.d b/src/dfmt.d index df9a8df..a795cfc 100644 --- a/src/dfmt.d +++ b/src/dfmt.d @@ -816,6 +816,12 @@ private: writeToken(); // switch write(" "); writeParens(true); + if (current.type == tok!"with") + { + writeToken(); + write(" "); + writeParens(true); + } if (current.type != tok!"{") return; if (config.braceStyle == BraceStyle.otbs) @@ -853,12 +859,27 @@ private: writeToken(); write(" "); } - else if (current.type == tok!":" && peekIs(tok!"..")) + else if (current.type == tok!":") { - writeToken(); - write(" "); - writeToken(); - write(" "); + if (peekIs(tok!"..")) + { + writeToken(); + write(" "); + writeToken(); + write(" "); + } + else if (peekIs(tok!"identifier") && peek2Is(tok!":")) + { + writeToken(); + indentLevel++; + newline(); + writeToken(); + writeToken(); + indentLevel++; + newline(); + } + else + goto peek; } else { diff --git a/tests/issue0043.d b/tests/issue0043.d new file mode 100644 index 0000000..df9f8ad --- /dev/null +++ b/tests/issue0043.d @@ -0,0 +1,12 @@ +unittest +{ + switch (something) with (stuff){ + case 1: case 2: +label:doStuff(); + case 3: + doOtherSTuff(); + goto label; +default: +break; +} +} diff --git a/tests/issue0043.d.ref b/tests/issue0043.d.ref new file mode 100644 index 0000000..4f171c4 --- /dev/null +++ b/tests/issue0043.d.ref @@ -0,0 +1,15 @@ +unittest +{ + switch (something) with (stuff) + { + case 1: + case 2: + label: + doStuff(); + case 3: + doOtherSTuff(); + goto label; + default: + break; + } +}