From ac8e34815f15469ac2b824dcb49b60f9145c29b5 Mon Sep 17 00:00:00 2001 From: sobaya Date: Sun, 4 Aug 2019 13:04:39 +0900 Subject: [PATCH] Fix: Use more readable expression --- src/dfmt/formatter.d | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dfmt/formatter.d b/src/dfmt/formatter.d index 18f958c..04d80bd 100644 --- a/src/dfmt/formatter.d +++ b/src/dfmt/formatter.d @@ -725,7 +725,7 @@ private: void formatColon() { import dfmt.editorconfig : OptionalBoolean; - import std.algorithm : canFind; + import std.algorithm : canFind, any; immutable bool isCase = astInformation.caseEndLocations.canFindIndex(current.index); immutable bool isAttribute = astInformation.attributeDeclarationLines.canFindIndex( @@ -747,10 +747,10 @@ private: newline(); } } - else if (peekBackIs(tok!"identifier") && (peekBack2Is(tok!"{", true) - || peekBack2Is(tok!"}", true) || peekBack2Is(tok!";", true) - || peekBack2Is(tok!":", true) || peekBack2Is(tok!",", true)) - && !(isBlockHeader(1) && !peekIs(tok!"if"))) + else if (peekBackIs(tok!"identifier") + && [tok!"{", tok!"}", tok!";", tok!":", tok!","] + .any!((ptrdiff_t token) => peekBack2Is(cast(IdType)token, true)) + && (!isBlockHeader(1) || peekIs(tok!"if"))) { writeToken(); if (isStructInitializer)