forked from qt-creator/qt-creator
CppEditor: Fix indentation for structured binding
Structured bindings were parsed as lambdas instead Fixes: QTCREATORBUG-27183 Change-Id: I3c88dc1012e55edfe417504c17f6138e3356651c Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -172,6 +172,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
|
|||||||
case T_COLON: enter(member_init_open); enter(member_init_expected); break;
|
case T_COLON: enter(member_init_open); enter(member_init_expected); break;
|
||||||
case T_OPERATOR: enter(operator_declaration); break;
|
case T_OPERATOR: enter(operator_declaration); break;
|
||||||
case T_GREATER_GREATER: break;
|
case T_GREATER_GREATER: break;
|
||||||
|
case T_LBRACKET: break;
|
||||||
default: tryExpression(true); break;
|
default: tryExpression(true); break;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@@ -128,6 +128,7 @@ private Q_SLOTS:
|
|||||||
void initializerWithinFunctionArg();
|
void initializerWithinFunctionArg();
|
||||||
void shiftWithinInitializer();
|
void shiftWithinInitializer();
|
||||||
void lambdaWithReturnType();
|
void lambdaWithReturnType();
|
||||||
|
void structuredBinding();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Line {
|
struct Line {
|
||||||
@@ -2209,6 +2210,17 @@ void tst_CodeFormatter::lambdaWithReturnType()
|
|||||||
checkIndent(data);
|
checkIndent(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_CodeFormatter::structuredBinding()
|
||||||
|
{
|
||||||
|
QList<Line> data;
|
||||||
|
data << Line("int main() {")
|
||||||
|
<< Line(" auto [v1, v2] = tuple_func();")
|
||||||
|
<< Line(" return 0;")
|
||||||
|
<< Line("}")
|
||||||
|
;
|
||||||
|
checkIndent(data);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_CodeFormatter)
|
QTEST_MAIN(tst_CodeFormatter)
|
||||||
|
|
||||||
#include "tst_codeformatter.moc"
|
#include "tst_codeformatter.moc"
|
||||||
|
Reference in New Issue
Block a user