From 5eef96e797428f3359e93626cd77a39d1483d115 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Sat, 7 Mar 2015 19:28:12 -0800 Subject: [PATCH] Fix #53 --- src/dfmt.d | 25 ++++++++----------------- tests/issue0053.d | 6 ++++++ tests/issue0053.d.ref | 7 +++++++ 3 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 tests/issue0053.d create mode 100644 tests/issue0053.d.ref 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;