forked from qt-creator/qt-creator
CppTools: Fix indentation for concatenated strings
Change-Id: I801a56804e7873be75a9ebc085dc3f4a2d64ea35 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
5416557a0b
commit
aeb2cfbc4f
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user