From aeb2cfbc4fe7685550fb6b10ef7146c98c19e821 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 26 Mar 2014 18:54:04 +0200 Subject: CppTools: Fix indentation for concatenated strings Change-Id: I801a56804e7873be75a9ebc085dc3f4a2d64ea35 Reviewed-by: Nikolai Kosjar --- src/plugins/cpptools/cppcodeformatter.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/plugins/cpptools/cppcodeformatter.cpp') diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp index c2ac2fb88d..9ee2fa8815 100644 --- a/src/plugins/cpptools/cppcodeformatter.cpp +++ b/src/plugins/cpptools/cppcodeformatter.cpp @@ -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 -- cgit v1.2.1