r238841 - clang-format: [JS] Fix incorrect line length calculation.

Daniel Jasper djasper at google.com
Tue Jun 2 08:14:21 PDT 2015


Author: djasper
Date: Tue Jun  2 10:14:21 2015
New Revision: 238841

URL: http://llvm.org/viewvc/llvm-project?rev=238841&view=rev
Log:
clang-format: [JS] Fix incorrect line length calculation.

Modified:
    cfe/trunk/lib/Format/ContinuationIndenter.cpp
    cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=238841&r1=238840&r2=238841&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Jun  2 10:14:21 2015
@@ -159,7 +159,8 @@ bool ContinuationIndenter::mustBreak(con
   if (((Previous.is(TT_DictLiteral) && Previous.is(tok::l_brace)) ||
        Previous.is(TT_ArrayInitializerLSquare)) &&
       Style.ColumnLimit > 0 &&
-      getLengthToMatchingParen(Previous) + State.Column > getColumnLimit(State))
+      getLengthToMatchingParen(Previous) + State.Column - 1 >
+          getColumnLimit(State))
     return true;
   if (Current.is(TT_CtorInitializerColon) &&
       ((Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All) ||

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=238841&r1=238840&r2=238841&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Jun  2 10:14:21 2015
@@ -259,7 +259,8 @@ TEST_F(FormatTestJS, ArrayLiterals) {
                "]);");
   verifyFormat("var someVariable = SomeFuntion([\n"
                "  [aaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbb],\n"
-               "]);");
+               "]);",
+               getGoogleJSStyleWithColumns(51));
   verifyFormat("var someVariable = SomeFuntion(aaaa, [\n"
                "  aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
                "  bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"





More information about the cfe-commits mailing list