Index: cfe/trunk/lib/Format/TokenAnnotator.cpp =================================================================== --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -2706,6 +2706,9 @@ Keywords.kw_readonly, Keywords.kw_abstract, Keywords.kw_get, Keywords.kw_set)) return false; // Otherwise automatic semicolon insertion would trigger. + if (Left.Tok.getIdentifierInfo() && + Right.startsSequence(tok::l_square, tok::r_square)) + return false; // breaking in "foo[]" creates illegal TS type syntax. if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace)) return false; if (Left.is(TT_JsTypeColon)) Index: cfe/trunk/unittests/Format/FormatTestJS.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -1426,6 +1426,8 @@ verifyFormat( "var someValue = (v as aaaaaaaaaaaaaaaaaaaa[])\n" " .someFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); + verifyFormat("const xIsALongIdent:\n"" YJustBarelyFitsLinex[];", + getGoogleJSStyleWithColumns(20)); } TEST_F(FormatTestJS, UnionIntersectionTypes) {