From eb505347cbe83c22498cee3356da3fda62903ff0 Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Fri, 16 Sep 2016 19:44:47 +0200 Subject: [PATCH] Keep spaceIndentCount for the current line to handle lambda expressions in multiline statements: std::generate(data.begin(), data.end(), [&]() { return randval(engine); }); --- src/ASBeautifier.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ASBeautifier.cpp b/src/ASBeautifier.cpp index 827ba42..2d1276c 100644 --- a/src/ASBeautifier.cpp +++ b/src/ASBeautifier.cpp @@ -2836,7 +2836,13 @@ void ASBeautifier::parseCurrentLine(const string& line) if (lineBeginsWithOpenBracket || lineBeginsWithComma) spaceIndentCount = 0; } - else + // Do not zero the spaceIndentCount for the current line + // if we are within a statement. This is useful for lambda + // expressions in multiline statements: + // + // std::generate(data.begin(), data.end(), + // [&]() { return randval(engine); }); + else if (!isInStatement || lineBeginsWithOpenBracket) spaceIndentCount = 0; }