Added a comment and another test for the UT_ForIndentation option

llvm-svn: 191530
This commit is contained in:
Alexander Kornienko 2013-09-27 16:40:11 +00:00
parent 8ba68f6802
commit 45dc1b2fd3
2 changed files with 15 additions and 1 deletions

View File

@ -290,6 +290,8 @@ void WhitespaceManager::appendIndentText(std::string &Text,
case FormatStyle::UT_ForIndentation:
if (WhitespaceStartColumn == 0) {
unsigned Indentation = IndentLevel * Style.IndentWidth;
// This happens, e.g. when a line in a block comment is indented less than
// the first one.
if (Indentation > Spaces)
Indentation = Spaces;
unsigned Tabs = Indentation / Style.TabWidth;

View File

@ -5932,7 +5932,19 @@ TEST_F(FormatTest, ConfigurableUseOfTab) {
"\t/*\n"
"\n"
"\t*/\n"
"}", Tab));
"}",
Tab));
EXPECT_EQ("{\n"
"\t/*\n"
" asdf\n"
"\t*/\n"
"}",
format("{\n"
"\t/*\n"
" asdf\n"
"\t*/\n"
"}",
Tab));
Tab.UseTab = FormatStyle::UT_Never;
EXPECT_EQ("/*\n"