diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2014-05-16 09:10:40 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2014-05-16 15:59:56 +0200 |
commit | 904a1d78f410f9c6778deeace932524aa5fa2d61 (patch) | |
tree | f77a0da71b05380abc909f11e6b89856af955639 /src/plugins/cpptools/cppcodeformatter.cpp | |
parent | 60c4235becbde78012232b342acca5946dbe6d8d (diff) | |
download | qt-creator-904a1d78f410f9c6778deeace932524aa5fa2d61.tar.gz |
CppTools: Fix indentation of stream operators after string
Task-number: QTCREATORBUG-12053
Change-Id: Ia34165d860bd7fd371a84a8349bed7a3fe1c01a9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cppcodeformatter.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcodeformatter.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp index 4d98a0c1c2..1923d976e9 100644 --- a/src/plugins/cpptools/cppcodeformatter.cpp +++ b/src/plugins/cpptools/cppcodeformatter.cpp @@ -1437,8 +1437,7 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd break; case string_open: - *indentDepth = tokenPosition; - *paddingDepth = 0; + *paddingDepth = tokenPosition - *indentDepth; break; } @@ -1467,16 +1466,25 @@ void QtStyleCodeFormatter::adjustIndent(const QList<CPlusPlus::Token> &tokens, i // adjusting the indentDepth here instead of in enter() gives 'else if' the correct indentation // ### could be moved? - if (topState.type == substatement) + switch (topState.type) { + case substatement: *indentDepth += m_tabSettings.m_indentSize; - + break; // keep user-adjusted indent in multiline comments - if (topState.type == multiline_comment_start - || topState.type == multiline_comment_cont) { + case multiline_comment_start: + case multiline_comment_cont: if (!tokens.isEmpty()) { *indentDepth = column(tokens.at(0).bytesBegin()); return; } + break; + case string_open: + if (!tokenAt(0).isStringLiteral()) { + *paddingDepth = topState.savedPaddingDepth; + topState = previousState; + previousState = state(2); + } + break; } const int kind = tokenAt(0).kind(); |