ClangFormat: Do not remove empty lines while only indenting

Insert dummy text into empty lines also for the electic characters
not to remove empty lines when only indentation is intended.

Fixes: QTCREATORBUG-22050
Change-Id: Ife5374459feb510a0587880a6772c90a2d68d70e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2019-03-05 17:16:29 +01:00
parent dc9c9249fc
commit ad8cabdf45
2 changed files with 20 additions and 15 deletions

View File

@@ -362,6 +362,23 @@ TEST_F(ClangFormat, IndentEmptyLineAndKeepPreviousEmptyLines)
"}"));
}
TEST_F(ClangFormat, IndentOnElectricCharacterButNotRemoveEmptyLinesBefore)
{
insertLines({"{",
" ",
" ",
"if ()",
"}"});
indenter.indentBlock(doc.findBlockByNumber(3), '(', TextEditor::TabSettings());
ASSERT_THAT(documentLines(), ElementsAre("{",
" ",
" ",
" if ()",
"}"));
}
TEST_F(ClangFormat, IndentFunctionBodyButNotFormatBeforeIt)
{
insertLines({"int foo(int a, int b,",