summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/cpptools/cppcodeformatter.cpp2
-rw-r--r--tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp15
2 files changed, 17 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index ebe66ce792..4a355f6ffb 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -195,6 +195,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
case T_RBRACE: leave(true); continue;
case T_SEMICOLON: leave(); continue;
case T_RPAREN: leave(); continue;
+ case T_COMMA: leave(); continue;
default: enter(assign_open); continue;
} break;
@@ -218,6 +219,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
case T_RBRACE: leave(true); continue;
case T_SEMICOLON: leave(); continue;
case T_RPAREN: leave(); continue;
+ case T_COMMA: leave(); continue;
default: tryExpression(); break;
} break;
diff --git a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
index ab80877202..3df75d4f37 100644
--- a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
+++ b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp
@@ -73,6 +73,7 @@ private Q_SLOTS:
void bug1();
void bug2();
void bug3();
+ void bug4();
void switch1();
void switch2();
void switch3();
@@ -778,6 +779,20 @@ void tst_CodeFormatter::bug3()
checkIndent(data);
}
+void tst_CodeFormatter::bug4()
+{
+ QList<Line> data;
+ data << Line("void test()")
+ << Line("{")
+ << Line(" int a = 0, b = {0};")
+ << Line(" int a = {0}, b = {0};")
+ << Line(" int b;")
+ << Line("}")
+ << Line("int c;")
+ ;
+ checkIndent(data);
+}
+
void tst_CodeFormatter::braceList()
{
QList<Line> data;