Skip to content

Commit

Permalink
[clang-format] Fix comment indentation in text protos
Browse files Browse the repository at this point in the history
Summary: This patch fixes a bug where the comment indent of comments in text protos gets messed up because by default paren states get created with AlignColons = true (which makes snese for ObjC).

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D43194

llvm-svn: 324896
  • Loading branch information
krasimirgg committed Feb 12, 2018
1 parent 8ea7ede commit c8b461b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/lib/Format/ContinuationIndenter.cpp
Expand Up @@ -200,6 +200,7 @@ LineState ContinuationIndenter::getInitialState(unsigned FirstIndent,
// global scope.
State.Stack.back().AvoidBinPacking = true;
State.Stack.back().BreakBeforeParameter = true;
State.Stack.back().AlignColons = false;
}

// The first token has already been indented and thus consumed.
Expand Down
12 changes: 12 additions & 0 deletions clang/unittests/Format/FormatTestTextProto.cpp
Expand Up @@ -313,5 +313,17 @@ TEST_F(FormatTestTextProto, KeepsLongStringLiteralsOnSameLine) {
" text: \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaaaaaaaa\"\n"
"}");
}

TEST_F(FormatTestTextProto, KeepsCommentsIndentedInList) {
verifyFormat("aaaaaaaaaa: 100\n"
"bbbbbbbbbbbbbbbbbbbbbbbbbbb: 200\n"
"# Single line comment for stuff here.\n"
"cccccccccccccccccccccccc: 3849\n"
"# Multiline comment for stuff here.\n"
"# Multiline comment for stuff here.\n"
"# Multiline comment for stuff here.\n"
"cccccccccccccccccccccccc: 3849");
}

} // end namespace tooling
} // end namespace clang

0 comments on commit c8b461b

Please sign in to comment.