summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2010-09-08 15:49:09 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2010-09-08 15:50:07 +0200
commit34f37fb5e36c60926ba1bda8c93181c5d67654f7 (patch)
tree855572478ee6ac9608a4f6057d5e9c723af751d7
parentcb23999fbf16476d52678d23fc3cf888090560bf (diff)
downloadqt-creator-34f37fb5e36c60926ba1bda8c93181c5d67654f7.tar.gz
QmlJS indenter: Fix one-line object declarations in array bindings.
Task-number: QTCREATORBUG-2295
-rw-r--r--src/plugins/qmljseditor/qmljseditorcodeformatter.cpp11
-rw-r--r--tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp3
2 files changed, 4 insertions, 10 deletions
diff --git a/src/plugins/qmljseditor/qmljseditorcodeformatter.cpp b/src/plugins/qmljseditor/qmljseditorcodeformatter.cpp
index 0547253553..ad296a74b2 100644
--- a/src/plugins/qmljseditor/qmljseditorcodeformatter.cpp
+++ b/src/plugins/qmljseditor/qmljseditorcodeformatter.cpp
@@ -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;
}
diff --git a/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp b/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp
index 4f5d8464ba..49c30915f3 100644
--- a/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp
+++ b/tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp
@@ -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"