This is an archive of the discontinued LLVM Phabricator instance.

clang-format: [JS] avoid line breaks before unindented r_parens.
ClosedPublic

Authored by mprobst on May 22 2017, 3:01 AM.

Details

Summary

The change that enabled wrapping at the previous scope's indentation had
unintended side-effects in that clang-format would prefer to wrap
closing parentheses to the next line if it avoided a wrap on the next
line (assuming very narrow lines):

fooObject
    .someCall(barbazbam)
    .then(bam);

Would get formatted as:

fooObject.someCall(barbazbam
).then(bam);

Because the ')' is now indented at the parent level (fooObject).

Normally formatting a builder pattern style call sequence like that is
outlawed in clang-format anyway. However for JavaScript this is special
cased to support trailing .bind calls.

This change disallows this special case when following a closing ')' to
avoid the problem.

Included are some random comment fixes.

Diff Detail

Repository
rL LLVM

Event Timeline

mprobst created this revision.May 22 2017, 3:01 AM
mprobst updated this revision to Diff 99762.May 22 2017, 7:33 AM
  • fix the issue, update description with cause
mprobst retitled this revision from clang-format: [JS] add a test for ! before ). to clang-format: [JS] avoid line breaks before unindented r_parens..May 22 2017, 7:34 AM
mprobst edited the summary of this revision. (Show Details)
djasper accepted this revision.May 22 2017, 7:46 AM
This revision is now accepted and ready to land.May 22 2017, 7:46 AM
This revision was automatically updated to reflect the committed changes.