This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix reflow in block comment lines with leading whitespace.
ClosedPublic

Authored by krasimir on Jan 31 2017, 6:26 AM.

Details

Summary

The reflower was not taking into account the additional leading whitespace in block comment lines.

source:

{
/*
 * long long long long
 *   long
 * long long long long
 */
}

format (with column limit 20) before:

{
  /*
   * long long long
   * long long long long
   * long long
   */
}

format after:

{
  /*
   * long long long
   * long long long
   * long long long
   */
}

Diff Detail

Repository
rL LLVM

Event Timeline

krasimir created this revision.Jan 31 2017, 6:26 AM
krasimir edited the summary of this revision. (Show Details)Jan 31 2017, 6:30 AM
krasimir added reviewers: djasper, klimek.
krasimir added subscribers: sammccall, cfe-commits.
djasper accepted this revision.Jan 31 2017, 6:35 AM

I don't know. I could also make an argument that more than one space at the beginning of a line should just stop the reflow. E.g. I could see people writing paragraphs like this:

/*
 * This is my long text. This is
 * paragraph one.
 *   If I add two or three spaces,
 * here, it's probably easy to see
 * that this is separate.
 */

That said, I am fine submitting this for now.

This revision is now accepted and ready to land.Jan 31 2017, 6:35 AM
This revision was automatically updated to reflect the committed changes.

@djasper: I agree with the two spaces rule. Sounds pretty reasonable. Will add this feature eventually.