forked from qt-creator/qt-creator
CppTools: Fix formatting for lambdas with trailing return type
After the arrow, the state is still the same, as now a type is expected. Only after the opening brace does the actual function start. Fixes: QTCREATORBUG-18497 Change-Id: I7bf18fbd6907d36f8869af3a78ad617cf0ee9dbb Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -127,6 +127,7 @@ private Q_SLOTS:
|
||||
void strings();
|
||||
void initializerWithinFunctionArg();
|
||||
void shiftWithinInitializer();
|
||||
void lambdaWithReturnType();
|
||||
};
|
||||
|
||||
struct Line {
|
||||
@@ -2196,6 +2197,18 @@ void tst_CodeFormatter::shiftWithinInitializer()
|
||||
checkIndent(data);
|
||||
}
|
||||
|
||||
void tst_CodeFormatter::lambdaWithReturnType()
|
||||
{
|
||||
QList<Line> data;
|
||||
data << Line("int main() {")
|
||||
<< Line(" hello([]() -> void {")
|
||||
<< Line(" cout << \"world\";") // OK, same indentation/padding as above.
|
||||
<< Line(" });")
|
||||
<< Line("}")
|
||||
;
|
||||
checkIndent(data);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_CodeFormatter)
|
||||
|
||||
#include "tst_codeformatter.moc"
|
||||
|
||||
Reference in New Issue
Block a user