Commit 12a1ba08 authored by Christian Kamm's avatar Christian Kamm

QmlJS indenter: Fix indent after do-while without semicolon.

Change-Id: I4909f4640e7cd115b6c5c54c7aca7fca511653c9
Reviewed-by: default avatarLeandro Melo <leandro.melo@nokia.com>
parent af8b381f
......@@ -430,7 +430,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
switch (kind) {
case While: break;
case LeftParenthesis: enter(do_statement_while_paren_open); break;
default: leave(true); break;
default: leave(true); continue; // error recovery
} break;
case do_statement_while_paren_open:
......@@ -788,6 +788,7 @@ bool CodeFormatter::isExpressionEndState(int type) const
type == top_js ||
type == objectdefinition_open ||
type == if_statement ||
type == do_statement ||
type == else_clause ||
type == jsblock_open ||
type == substatement_open ||
......
......@@ -77,6 +77,7 @@ private Q_SLOTS:
void whileStatement();
void tryStatement();
void doWhile();
void doWhile2();
void cStyleComments();
void cppStyleComments();
void qmlKeywords();
......@@ -858,6 +859,24 @@ void tst_QMLCodeFormatter::doWhile()
checkIndent(data);
}
void tst_QMLCodeFormatter::doWhile2()
{
QList<Line> data;
data << Line("function foo() {")
<< Line(" do { if (c) foo; } while (a)")
<< Line(" do {")
<< Line(" if (a);")
<< Line(" } while (a)")
<< Line(" do")
<< Line(" foo;")
<< Line(" while (a)")
<< Line(" do foo; while (a)")
<< Line("}")
<< Line("var x")
;
checkIndent(data);
}
void tst_QMLCodeFormatter::cStyleComments()
{
QList<Line> data;
......@@ -1174,7 +1193,7 @@ void tst_QMLCodeFormatter::labelledStatements1()
<< Line(" while (1) {")
<< Line(" break lab")
<< Line(" }")
<< Line(" }")
<< Line(" } while (1)")
<< Line("}")
<< Line("var x = function() {")
<< Line(" x + 1;")
......
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