diff --git a/src/dfmt.d b/src/dfmt.d index 0631085..5603c08 100644 --- a/src/dfmt.d +++ b/src/dfmt.d @@ -313,17 +313,6 @@ private: case tok!"(": writeParens(true); break; - case tok!":": - if (!assumeSorted(astInformation.ternaryColonLocations) - .equalRange(current.index).empty) - { - write(" "); - writeToken(); - write(" "); - } - else - writeToken(); - break; case tok!"@": case tok!"!": case tok!"...": @@ -333,6 +322,10 @@ private: case tok!"$": writeToken(); break; + case tok!":": + write(" : "); + index += 1; + break; case tok!"]": writeToken(); if (current.type == tok!"identifier") @@ -811,9 +804,6 @@ struct ASTInformation /// Locations of unary operators size_t[] unaryLocations; - - /// Locations of ':' operators in ternary expressions - size_t[] ternaryColonLocations; } /// Collects information from the AST that is useful for the formatter @@ -886,13 +876,6 @@ final class FormatVisitor : ASTVisitor unary.accept(this); } - override void visit(const TernaryExpression ternary) - { - if (ternary.colon.type != tok!"") - astInformation.ternaryColonLocations ~= ternary.colon.index; - ternary.accept(this); - } - private: ASTInformation* astInformation; alias visit = ASTVisitor.visit;