]> granicus.if.org Git - clang/commit
clang-format: [JS] avoid line breaks before unindented r_parens.
authorMartin Probst <martin@probst.io>
Mon, 22 May 2017 14:58:26 +0000 (14:58 +0000)
committerMartin Probst <martin@probst.io>
Mon, 22 May 2017 14:58:26 +0000 (14:58 +0000)
commit0e60ff1591431fb3ccfa49df2d6dfed36b6de932
tree8491901a2e1ff8dd10d72adb10728a0f1961a4cc
parent6c88fb85c25e7f2b5fbab3a60fb62e1653008b9d
clang-format: [JS] avoid line breaks before unindented r_parens.

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.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D33399

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303557 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/ContinuationIndenter.cpp
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJS.cpp