diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 0c94c52622a4e807a0d9110a42fb22237cf50e1b..f36b2c8a73dc9e8243fc0f0ce30e22029f483c0d 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -363,6 +363,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { // // We exclude + and - as they can be ObjC visibility modifiers. ProbablyBracedList = + (Style.Language == FormatStyle::LK_JavaScript && + NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in)) || NextTok->isOneOf(tok::comma, tok::period, tok::colon, tok::r_paren, tok::r_square, tok::l_brace, tok::l_square, tok::l_paren, tok::ellipsis) || diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 589a7e48da3c35ad62466ddaabbef66bc716342a..6af4a69257f6d16457fd9be15aa21d7d6ecaa99c 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -606,6 +606,10 @@ TEST_F(FormatTestJS, ForLoops) { "}"); verifyFormat("for (var i of [2, 3]) {\n" "}"); + verifyFormat("for (let {a, b} of x) {\n" + "}"); + verifyFormat("for (let {a, b} in x) {\n" + "}"); } TEST_F(FormatTestJS, AutomaticSemicolonInsertion) {