ClangFormat: Indent closing brace on the new line

Sometimes the curly brace also requires indentation.
These are the cases when it comes directly after the
comma, for example inside the initializer list.

Lets handle such cases in the similar way we do it for
the closing parenthesis.

Change-Id: Ia0d25fa08f7224567dd41dd17f9757d9d8b27362
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2019-03-11 12:30:10 +01:00
parent 1959664210
commit cb3a553583
2 changed files with 42 additions and 5 deletions

View File

@@ -417,6 +417,30 @@ TEST_F(ClangFormat, EmptyLineInInitializerList)
"};"));
}
TEST_F(ClangFormat, IndentClosingBraceAfterComma)
{
insertLines({"Bar foo{a,",
"}"});
indenter.indentBlock(doc.findBlockByNumber(1), QChar::Null, TextEditor::TabSettings());
ASSERT_THAT(documentLines(), ElementsAre("Bar foo{a,",
" }"));
}
TEST_F(ClangFormat, DoNotIndentClosingBraceAfterSemicolon)
{
insertLines({"{",
" a;"
"}"});
indenter.indentBlock(doc.findBlockByNumber(2), QChar::Null, TextEditor::TabSettings());
ASSERT_THAT(documentLines(), ElementsAre("{",
" a;"
"}"));
}
TEST_F(ClangFormat, IndentFunctionBodyButNotFormatBeforeIt)
{
insertLines({"int foo(int a, int b,",