diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 93d0400..c957c9a 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -761,7 +761,7 @@ private: write("}"); if (index + 1 < tokens.length && astInformation.doubleNewlineLocations.canFindIndex( - tokens[index].index) && !peekIs(tok!"}") + tokens[index].index) && !peekIs(tok!"}") && !peekIs(tok!";") && !peekIs(tok!"comment", false)) { simpleNewline(); @@ -1214,7 +1214,7 @@ private: if (niBraceDepth > 0 && !peekBackIsSlashSlash() && hasCurrent && tokens[index].type == tok!"}" && !assumeSorted(astInformation.funLitEndLocations).equalRange( - tokens[index].index).empty) + tokens[index].index).empty) { write(" "); return; @@ -1298,7 +1298,7 @@ private: } while (sBraceDepth == 0 && indents.topIsTemp() && ((indents.top != tok!"if" - && indents.top != tok!"version") || !peekIs(tok!"else"))) + && indents.top != tok!"version") || !peekIs(tok!"else"))) { indents.pop(); } @@ -1329,12 +1329,10 @@ private: } else { - indents.dump(); if (indents.topIsTemp() && (peekBackIsOneOf(true, tok!"}", tok!";") && indents.top != tok!";")) indents.popTempIndents(); indentLevel = indents.indentLevel; - indents.dump(); } indent(); } diff --git a/src/dfmt/indentation.d b/src/dfmt/indentation.d index 489f418..1a4ab51 100644 --- a/src/dfmt/indentation.d +++ b/src/dfmt/indentation.d @@ -151,14 +151,14 @@ struct IndentStack return cast(int) index; } - void dump() + /+void dump() { - /+import std.stdio : stderr; + import std.stdio : stderr; import dparse.lexer : str; import std.algorithm.iteration : map; - stderr.writefln("\033[31m%(%s %)\033[0m", arr[0 .. index].map!(a => str(a)));+/ - } + stderr.writefln("\033[31m%(%s %)\033[0m", arr[0 .. index].map!(a => str(a))); + }+/ private: @@ -188,7 +188,7 @@ private: parenCount = 0; continue; } - //parenCount = 0; + parenCount = 0; } immutable currentIsNonWrapTemp = !isWrapIndent(arr[i]) && isTempIndent(arr[i]); immutable nextIsParenOrSwitch = arr[i + 1] == tok!"("