C++ indenter: Fix indentation if template and class appear on one line.

Task-number: QTCREATORBUG-2427
This commit is contained in:
Christian Kamm
2010-09-24 15:08:08 +02:00
parent be563abf68
commit d7bf4f515d
2 changed files with 22 additions and 6 deletions

View File

@@ -1040,16 +1040,18 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
switch (newState) {
case namespace_start:
if (firstToken)
if (firstToken) {
*savedIndentDepth = tokenPosition;
*indentDepth = tokenPosition;
*indentDepth = tokenPosition;
}
break;
case enum_start:
case class_start:
if (firstToken)
if (firstToken) {
*savedIndentDepth = tokenPosition;
*indentDepth = tokenPosition;
*indentDepth = tokenPosition;
}
*paddingDepth = 2*m_indentSize;
break;
@@ -1075,9 +1077,10 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
break;
case declaration_start:
if (firstToken)
if (firstToken) {
*savedIndentDepth = tokenPosition;
*indentDepth = *savedIndentDepth;
*indentDepth = *savedIndentDepth;
}
// continuation indent in function bodies only, to not indent
// after the return type in "void\nfoo() {}"
for (int i = 0; state(i).type != topmost_intro; ++i) {