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:
GPery
2022-03-17 13:20:07 +02:00
committed by gpery+qt
parent 355c5a7c73
commit f99094a0b8
2 changed files with 13 additions and 0 deletions

View File

@@ -172,6 +172,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
case T_COLON: enter(member_init_open); enter(member_init_expected); break;
case T_OPERATOR: enter(operator_declaration); break;
case T_GREATER_GREATER: break;
case T_LBRACKET: break;
default: tryExpression(true); break;
} break;

View File

@@ -128,6 +128,7 @@ private Q_SLOTS:
void initializerWithinFunctionArg();
void shiftWithinInitializer();
void lambdaWithReturnType();
void structuredBinding();
};
struct Line {
@@ -2209,6 +2210,17 @@ void tst_CodeFormatter::lambdaWithReturnType()
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)
#include "tst_codeformatter.moc"