forked from qt-creator/qt-creator
QmlJS indenter: Fix one-line object declarations in array bindings.
Task-number: QTCREATORBUG-2295
This commit is contained in:
@@ -101,17 +101,10 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
|
|||||||
if (parentState.type == binding_assignment)
|
if (parentState.type == binding_assignment)
|
||||||
*savedIndentDepth = state(1).savedIndentDepth;
|
*savedIndentDepth = state(1).savedIndentDepth;
|
||||||
|
|
||||||
bool followedByData = (!lastToken && tokenAt(tokenIndex() + 1).kind != Token::Comment);
|
if (firstToken)
|
||||||
if (firstToken || followedByData)
|
|
||||||
*savedIndentDepth = tokenPosition;
|
*savedIndentDepth = tokenPosition;
|
||||||
|
|
||||||
*indentDepth = *savedIndentDepth;
|
*indentDepth = *savedIndentDepth + m_indentSize;
|
||||||
|
|
||||||
if (followedByData) {
|
|
||||||
*indentDepth = column(tokenAt(tokenIndex() + 1).begin());
|
|
||||||
} else {
|
|
||||||
*indentDepth += m_indentSize;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ void tst_QMLCodeFormatter::arrayBinding()
|
|||||||
<< Line(" State {")
|
<< Line(" State {")
|
||||||
<< Line(" y: x")
|
<< Line(" y: x")
|
||||||
<< Line(" },")
|
<< Line(" },")
|
||||||
|
<< Line(" State {},")
|
||||||
<< Line(" State")
|
<< Line(" State")
|
||||||
<< Line(" {")
|
<< Line(" {")
|
||||||
<< Line(" }")
|
<< Line(" }")
|
||||||
@@ -882,7 +883,7 @@ void tst_QMLCodeFormatter::expressionContinuation()
|
|||||||
checkIndent(data);
|
checkIndent(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(tst_CodeFormatter)
|
QTEST_APPLESS_MAIN(tst_QMLCodeFormatter)
|
||||||
#include "tst_qmlcodeformatter.moc"
|
#include "tst_qmlcodeformatter.moc"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user