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:
Christian Kandeler
2020-07-30 17:34:36 +02:00
parent 537e2e23ff
commit 3f9427200b
2 changed files with 20 additions and 1 deletions

View File

@@ -273,7 +273,13 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
case T_RBRACKET: // '[', ']' and '->' can be part of lambda declarator
case T_LBRACKET:
case T_ARROW: break;
default: leave(); continue;
default:
if (m_tokenIndex > 0 && tokenAt(m_tokenIndex - 1).kind() == T_ARROW) {
break;
} else {
leave();
continue;
}
} break;
case lambda_declarator: