diff --git a/src/dfmt.d b/src/dfmt.d index a795cfc..0611ac9 100644 --- a/src/dfmt.d +++ b/src/dfmt.d @@ -489,11 +489,10 @@ private: else { writeToken(); - if (!currentIs(tok!")", false) && !currentIs(tok!"}", false) - && !currentIs(tok!"]", false)) - { + if (currentIs(tok!"}", false)) + tempIndent = 0; + else if (!currentIs(tok!")", false) && !currentIs(tok!"]", false)) write(" "); - } } regenLineBreakHintsIfNecessary(index - 1); break; @@ -648,6 +647,7 @@ private: { import std.range : assumeSorted; int depth = 0; + immutable l = indentLevel; do { if (current.type == tok!"{") @@ -700,20 +700,11 @@ private: index++; if (index < tokens.length && current.type == tok!"else") write(" "); - else - { - if (peekIs(tok!"case") || peekIs(tok!"default")) - indentLevel--; - newline(); - } - } - else - { - index++; - if (peekIs(tok!"case") || peekIs(tok!"default")) - indentLevel--; - newline(); } + index++; + if (peekIs(tok!"case") || peekIs(tok!"default")) + indentLevel--; + newline(); } } else diff --git a/tests/issue0053.d b/tests/issue0053.d new file mode 100644 index 0000000..bf04f95 --- /dev/null +++ b/tests/issue0053.d @@ -0,0 +1,6 @@ +enum DYNCAST : int +{ +DYNCAST_OBJECT, DYNCAST_EXPRESSION, DYNCAST_DSYMBOL, DYNCAST_TYPE, + DYNCAST_IDENTIFIER, DYNCAST_TUPLE, DYNCAST_PARAMETER, +} +alias MATCHnomatch = MATCH.MATCHnomatch; diff --git a/tests/issue0053.d.ref b/tests/issue0053.d.ref new file mode 100644 index 0000000..7e89e6f --- /dev/null +++ b/tests/issue0053.d.ref @@ -0,0 +1,7 @@ +enum DYNCAST : int +{ + DYNCAST_OBJECT, DYNCAST_EXPRESSION, DYNCAST_DSYMBOL, DYNCAST_TYPE, + DYNCAST_IDENTIFIER, DYNCAST_TUPLE, DYNCAST_PARAMETER, +} + +alias MATCHnomatch = MATCH.MATCHnomatch;