From: Daniel Jasper Date: Tue, 2 Jun 2015 15:14:21 +0000 (+0000) Subject: clang-format: [JS] Fix incorrect line length calculation. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4f8924a5d1350e464e78e6a0c93fbb91b246153;p=clang clang-format: [JS] Fix incorrect line length calculation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238841 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 39b2793fee..204bcc9df4 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -159,7 +159,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { 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) || diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 25113ab758..a18d35b034 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -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"