forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -645,6 +645,7 @@ bool CodeFormatter::tryStatement()
|
|||||||
return true;
|
return true;
|
||||||
case Break:
|
case Break:
|
||||||
case Continue:
|
case Continue:
|
||||||
|
enter(breakcontinue_statement);
|
||||||
leave(true);
|
leave(true);
|
||||||
return true;
|
return true;
|
||||||
case Throw:
|
case Throw:
|
||||||
|
|||||||
@@ -143,7 +143,8 @@ public: // must be public to make Q_GADGET introspection work
|
|||||||
|
|
||||||
jsblock_open,
|
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'
|
if_statement, // After 'if'
|
||||||
maybe_else, // after the first substatement in an if
|
maybe_else, // after the first substatement in an if
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ private Q_SLOTS:
|
|||||||
void ifStatementWithoutBraces2();
|
void ifStatementWithoutBraces2();
|
||||||
void ifStatementWithBraces1();
|
void ifStatementWithBraces1();
|
||||||
void ifStatementWithBraces2();
|
void ifStatementWithBraces2();
|
||||||
|
void ifStatementWithBraces3();
|
||||||
void ifStatementMixed();
|
void ifStatementMixed();
|
||||||
void ifStatementAndComments();
|
void ifStatementAndComments();
|
||||||
void ifStatementLongCondition();
|
void ifStatementLongCondition();
|
||||||
@@ -543,6 +544,18 @@ void tst_QMLCodeFormatter::ifStatementWithBraces2()
|
|||||||
checkIndent(data);
|
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()
|
void tst_QMLCodeFormatter::ifStatementMixed()
|
||||||
{
|
{
|
||||||
QList<Line> data;
|
QList<Line> data;
|
||||||
|
|||||||
Reference in New Issue
Block a user