Commit fad5cc01 authored by Christian Kamm's avatar Christian Kamm Committed by Eike Ziller

QmlJS indenter: Fix hang when using 'else (a==a) {}'.

Change-Id: Id7b8fba6707b1eaabf8065854f357cf600c809c5
Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
(cherry picked from commit 567e68a4)
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent d530e8dd
......@@ -254,8 +254,13 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
case expression_or_label:
switch (kind) {
case Colon: turnInto(labelled_statement); break;
default: enter(expression); continue;
case Colon: turnInto(labelled_statement); break;
// propagate 'leave' from expression state
case RightBracket:
case RightParenthesis: leave(); continue;
default: enter(expression); continue;
} break;
case ternary_op:
......@@ -756,6 +761,7 @@ bool CodeFormatter::tryStatement()
case Function:
case Number:
case String:
case LeftParenthesis:
enter(expression);
// look at the token again
m_tokenIndex -= 1;
......
......@@ -96,6 +96,7 @@ private Q_SLOTS:
void labelledStatements3();
void multilineTernaryInProperty();
void multilineString();
void bug1();
};
enum { DontCheck = -2, DontIndent = -1 };
......@@ -1242,6 +1243,20 @@ void tst_QMLCodeFormatter::multilineString()
checkIndent(data);
}
void tst_QMLCodeFormatter::bug1()
{
QList<Line> data;
data << Line("Item {")
<< Line(" x: {")
<< Line(" if (a==a) {}")
<< Line(" else (b==b) {}")
<< Line(" foo()")
<< Line(" }")
<< Line("}")
;
checkIndent(data);
}
QTEST_APPLESS_MAIN(tst_QMLCodeFormatter)
#include "tst_qmlcodeformatter.moc"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment