From 008cc94a1e534d8a2640839f38b53488d772b445 Mon Sep 17 00:00:00 2001 From: Peter Vingelmann Date: Mon, 19 Sep 2016 20:04:20 +0200 Subject: [PATCH] Adjust indentation when the line starts or ends with << --- src/ASBeautifier.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ASBeautifier.cpp b/src/ASBeautifier.cpp index 11ba21e..6793e74 100644 --- a/src/ASBeautifier.cpp +++ b/src/ASBeautifier.cpp @@ -3563,9 +3563,19 @@ void ASBeautifier::parseCurrentLine(const string& line) { // this will be true if the line begins with the operator if (i < 2 && spaceIndentCount == 0) - spaceIndentCount += 2 * indentLength; - // align to the beginning column of the operator - registerInStatementIndent(line, i - foundNonAssignmentOp->length(), spaceIndentCount, tabIncrementIn, 0, false); + spaceIndentCount += indentLength; + // check if the line ends with << or >> + if (line.find_first_not_of(" \t", i + 1) == string::npos) + { + // this will only add one indentation from the left + registerInStatementIndent(line, i, spaceIndentCount, tabIncrementIn, 0, false); + } + else + { + // align to the beginning column of the operator + registerInStatementIndent(line, i - foundNonAssignmentOp->length(), + spaceIndentCount, tabIncrementIn, 0, false); + } } }