forked from qt-creator/qt-creator
CppEditor: Fix indentation of function call arguments
... following an argument with an array subscript operator. Fixes: QTCREATORBUG-29225 Change-Id: Iba38043d94be718efee30ce50f5b55aac4ba6ecd Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -204,7 +204,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
|
||||
case T_IDENTIFIER: // '&', id, 'this' are allowed both in the capture list and subscribtion
|
||||
case T_AMPER:
|
||||
case T_THIS: break;
|
||||
default: leave(); leave(); tryExpression(m_currentState.at(m_currentState.size() - 1).type == declaration_start); break;
|
||||
default: tryExpression(m_currentState.at(m_currentState.size() - 2).type == declaration_start); break;
|
||||
// any other symbol allowed only in subscribtion operator
|
||||
} break;
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ private Q_SLOTS:
|
||||
void shiftWithinInitializer();
|
||||
void lambdaWithReturnType();
|
||||
void structuredBinding();
|
||||
void subscriptOperatorInFunctionCall();
|
||||
};
|
||||
|
||||
struct Line {
|
||||
@@ -2199,6 +2200,19 @@ void tst_CodeFormatter::structuredBinding()
|
||||
checkIndent(data);
|
||||
}
|
||||
|
||||
void tst_CodeFormatter::subscriptOperatorInFunctionCall()
|
||||
{
|
||||
QList<Line> data;
|
||||
data << Line("int main() {")
|
||||
<< Line(" func(array[0],")
|
||||
<< Line(" ~ 0);")
|
||||
<< Line(" func(array[i],")
|
||||
<< Line(" ~ i);")
|
||||
<< Line("}")
|
||||
;
|
||||
checkIndent(data);
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(tst_CodeFormatter)
|
||||
|
||||
#include "tst_codeformatter.moc"
|
||||
|
||||
Reference in New Issue
Block a user