[PATCH] D43194: [clang-format] Fix comment indentation in text protos
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 12 07:50:07 PST 2018
krasimir created this revision.
Herald added subscribers: cfe-commits, klimek.
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).
Repository:
rC Clang
https://reviews.llvm.org/D43194
Files:
lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTestTextProto.cpp
Index: unittests/Format/FormatTestTextProto.cpp
===================================================================
--- unittests/Format/FormatTestTextProto.cpp
+++ unittests/Format/FormatTestTextProto.cpp
@@ -313,5 +313,17 @@
" 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
Index: lib/Format/ContinuationIndenter.cpp
===================================================================
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -200,6 +200,7 @@
// 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43194.133863.patch
Type: text/x-patch
Size: 1316 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180212/740e55b2/attachment.bin>
More information about the cfe-commits
mailing list