Commit b58ebe7d authored by Christian Kamm's avatar Christian Kamm

QmlJS indenter: Fix incorrect indent after break/continue.

Make sure to push a transitory state before leave(true) so it only
finishes the statement - and not the surrounding statement!

Reviewed-by: trustme
parent 4537a7eb
......@@ -645,6 +645,7 @@ bool CodeFormatter::tryStatement()
return true;
case Break:
case Continue:
enter(breakcontinue_statement);
leave(true);
return true;
case Throw:
......
......@@ -143,7 +143,8 @@ public: // must be public to make Q_GADGET introspection work
jsblock_open,
empty_statement, // for a ';', will never linger
empty_statement, // for a ';', will be popped directly
breakcontinue_statement, // for continue/break, will be popped directly
if_statement, // After 'if'
maybe_else, // after the first substatement in an if
......
......@@ -31,6 +31,7 @@ private Q_SLOTS:
void ifStatementWithoutBraces2();
void ifStatementWithBraces1();
void ifStatementWithBraces2();
void ifStatementWithBraces3();
void ifStatementMixed();
void ifStatementAndComments();
void ifStatementLongCondition();
......@@ -543,6 +544,18 @@ void tst_QMLCodeFormatter::ifStatementWithBraces2()
checkIndent(data);
}
void tst_QMLCodeFormatter::ifStatementWithBraces3()
{
QList<Line> data;
data << Line("function foo() {")
<< Line(" if (a) {")
<< Line(" continue")
<< Line(" }")
<< Line(" var foo")
<< Line("}");
checkIndent(data);
}
void tst_QMLCodeFormatter::ifStatementMixed()
{
QList<Line> data;
......
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