[PATCH] D33285: clang-format: do not reflow bullet lists
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 18 00:26:40 PDT 2017
krasimir added inline comments.
================
Comment at: lib/Format/BreakableToken.cpp:313
+ // Numbered lists may also start with a number followed by '.'
+ static const char *kNumberedListPattern = "^[0-9]+\\. ";
+ hasSpecialMeaningPrefix = hasSpecialMeaningPrefix ||
----------------
A problem with this is that sometimes you have a sentence ending with a number, like this one, in **2016.** If this sentence also happens to just go over the column width, its last part would be reflown and during subsequent passes it will be seen as a numbered list, which is super unfortunate. I'd like us to come up with a more refined strategy of handling this case. Maybe we should look at how others are doing it?
================
Comment at: lib/Format/BreakableToken.cpp:315
+ hasSpecialMeaningPrefix = hasSpecialMeaningPrefix ||
+ llvm::Regex(kNumberedListPattern).match(Content);
+
----------------
This builds an `llvm::Regex` on each invocation, which is wasteful.
================
Comment at: unittests/Format/FormatTestComments.cpp:1663
+ getLLVMStyleWithColumns(20)));
+
// Don't break or reflow after implicit string literals.
----------------
I'd also like to see tests where we correctly reflow lists with multiline entries.
https://reviews.llvm.org/D33285
More information about the cfe-commits
mailing list