forked from qt-creator/qt-creator
C++ indenter: Don't add continuation indent after function return type.
Task-number: QTCREATORBUG-1816
This commit is contained in:
@@ -932,7 +932,6 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
|
||||
case statement_with_condition:
|
||||
case for_statement:
|
||||
case switch_statement:
|
||||
case declaration_start:
|
||||
case if_statement:
|
||||
case return_statement:
|
||||
if (firstToken)
|
||||
@@ -940,6 +939,19 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
|
||||
*indentDepth = *savedIndentDepth + 2*m_indentSize;
|
||||
break;
|
||||
|
||||
case declaration_start:
|
||||
if (firstToken)
|
||||
*savedIndentDepth = tokenPosition;
|
||||
// continuation indent in function bodies only, to not indent
|
||||
// after the return type in "void\nfoo() {}"
|
||||
for (int i = 0; state(i).type != topmost_intro; ++i) {
|
||||
if (state(i).type == defun_open) {
|
||||
*indentDepth = *savedIndentDepth + 2*m_indentSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case arglist_open:
|
||||
case condition_paren_open:
|
||||
if (!lastToken)
|
||||
|
||||
Reference in New Issue
Block a user