[PATCH] D33285: clang-format: do not reflow bullet lists

Francois Ferrand via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 18 07:58:40 PDT 2017


Typz marked 3 inline comments as done.
Typz 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 ||
----------------
krasimir wrote:
> Typz wrote:
> > krasimir wrote:
> > > 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?
> > Looking at doxygen, it seems there is no extra protection: just a number followed by a dot...
> > So it means:
> >   * We should never break before a such a sequence, to avoid the issue.
> >   * We may also limit the expression to limit the size of the number: I am not sure there are cases where bullet lists with hundreds of items are used, esp. with explicit values (uses the auto-numbering -# would be much simpler in that case). Maybe a limit of 2 digits? The same limit would be applied to prevent breaking before a number followed by a dot.
> > 
> > What do you think?
> I like the combination of the two options: let's limit to 2 digits and not break before a matching numbered list sequence followed by a fullstop. That would require also a little change to `BreakableToken::getCommentSplit`.
Done, but I could find a use-case where this would break subsequent passes, apart from re-running clang-format ; but in this case it is fine, since the comments are already formatted to fit, and will thus not be reflowed... 


https://reviews.llvm.org/D33285





More information about the cfe-commits mailing list