CppTools: Fix indentation for concatenated strings

Change-Id: I801a56804e7873be75a9ebc085dc3f4a2d64ea35
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Orgad Shaneh
2014-03-26 18:54:04 +02:00
committed by Orgad Shaneh
parent 5416557a0b
commit aeb2cfbc4f
3 changed files with 35 additions and 1 deletions

View File

@@ -564,6 +564,13 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
case cpp_macro_cont:
break;
case string_open:
if (!m_currentToken.isStringLiteral()) {
leave();
continue;
}
break;
default:
qWarning() << "Unhandled state" << m_currentState.top().type;
break;
@@ -819,6 +826,9 @@ bool CodeFormatter::tryExpression(bool alsoExpression)
break;
}
if (m_currentToken.isStringLiteral())
newState = string_open;
if (newState != -1) {
if (alsoExpression)
enter(expression);
@@ -1425,6 +1435,11 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
case cpp_macro_cont:
*indentDepth = m_tabSettings.m_indentSize;
break;
case string_open:
*indentDepth = tokenPosition;
*paddingDepth = 0;
break;
}
// ensure padding and indent are >= 0

View File

@@ -180,7 +180,8 @@ public: // must be public to make Q_GADGET introspection work
lambda_statement_expected,
lambda_instroducer, // when '=', '&' or ',' occurred within '[]'
lambda_declarator, // just after ']' when previous state is lambda_introducer
lambda_statement // just after '{' when previous state is lambda_declarator or lambda_declarator_or_expression
lambda_statement, // just after '{' when previous state is lambda_declarator or lambda_declarator_or_expression
string_open
};
Q_ENUMS(StateType)