QmlJS indenter: Fix one-line object declarations in array bindings.

Task-number: QTCREATORBUG-2295
This commit is contained in:
Christian Kamm
2010-09-08 15:49:09 +02:00
parent cb23999fbf
commit 34f37fb5e3
2 changed files with 4 additions and 10 deletions

View File

@@ -101,17 +101,10 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
if (parentState.type == binding_assignment)
*savedIndentDepth = state(1).savedIndentDepth;
bool followedByData = (!lastToken && tokenAt(tokenIndex() + 1).kind != Token::Comment);
if (firstToken || followedByData)
if (firstToken)
*savedIndentDepth = tokenPosition;
*indentDepth = *savedIndentDepth;
if (followedByData) {
*indentDepth = column(tokenAt(tokenIndex() + 1).begin());
} else {
*indentDepth += m_indentSize;
}
*indentDepth = *savedIndentDepth + m_indentSize;
break;
}

View File

@@ -237,6 +237,7 @@ void tst_QMLCodeFormatter::arrayBinding()
<< Line(" State {")
<< Line(" y: x")
<< Line(" },")
<< Line(" State {},")
<< Line(" State")
<< Line(" {")
<< Line(" }")
@@ -882,7 +883,7 @@ void tst_QMLCodeFormatter::expressionContinuation()
checkIndent(data);
}
QTEST_APPLESS_MAIN(tst_CodeFormatter)
QTEST_APPLESS_MAIN(tst_QMLCodeFormatter)
#include "tst_qmlcodeformatter.moc"