ClangFormat: Enable includes sorting

Sort includes only in modes when all replacements are
used (manual indentation with "Format instead of indent" selected
and saving with "Format on save" activated).

Change-Id: I73dfa1d3211760269fe7d33a141f4d831ff65c15
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2019-03-06 12:47:45 +01:00
parent 7236e340a9
commit 35b0b44b21
2 changed files with 35 additions and 2 deletions

View File

@@ -633,6 +633,23 @@ TEST_F(ClangFormat, FormatTemplateparameters)
ASSERT_THAT(documentLines(), ElementsAre("using Alias = Template<A, B, C>"));
}
TEST_F(ClangFormat, SortIncludes)
{
insertLines({"#include \"b.h\"",
"#include \"a.h\"",
"",
"#include <bb.h>",
"#include <aa.h>"});
indenter.format({{1, 5}});
ASSERT_THAT(documentLines(), ElementsAre("#include \"a.h\"",
"#include \"b.h\"",
"",
"#include <aa.h>",
"#include <bb.h>"));
}
// clang-format on
} // namespace