From fab103cb473596b534fe53ca37d0a153a61fe156 Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Thu, 29 Sep 2016 00:20:55 +0200 Subject: [PATCH] Properly handle initializer blocks with double block openers. For example: std::map generation_map( { {0, 100}, {1, 100}, {2, 100}, {3, 10}, {4, 10} }); --- src/ASBeautifier.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ASBeautifier.cpp b/src/ASBeautifier.cpp index 4c044a0..246f9ca 100644 --- a/src/ASBeautifier.cpp +++ b/src/ASBeautifier.cpp @@ -2909,12 +2909,13 @@ void ASBeautifier::parseCurrentLine(const string& line) if (!inStatementIndentStack->empty()) { bool initializerBlock = - (isInStatement && (prevNonSpaceCh == ',' || prevNonSpaceCh == '(')); + (prevNonSpaceCh == ',' || prevNonSpaceCh == '(' + || prevNonSpaceCh == '{'); // Purge the inStatementIndentStack if the line begins with '{' // and this is not a possible initializer block in a statement, // for example: function(arg, { 1, 2, 3, 4 }); - if (lineBeginsWithOpenBracket && !initializerBlock) + if (i == 0 && !initializerBlock) { while (!inStatementIndentStack->empty()) popLastInStatementIndent();