diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 3b6628ecfbdd..ad40d99ad82c 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1321,7 +1321,7 @@ private: else if (Current->is(TT_LambdaArrow)) return prec::Comma; else if (Current->isOneOf(tok::semi, TT_InlineASMColon, - TT_SelectorName) || + TT_SelectorName, TT_JsComputedPropertyName) || (Current->is(tok::comment) && NextNonComment && NextNonComment->is(TT_SelectorName))) return 0; diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index d95ff9ba8341..29b8aa1ff13c 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -153,8 +153,11 @@ TEST_F(FormatTestJS, ContainerLiterals) { verifyFormat("var x = {y: (a) => a};"); // Computed keys. + verifyFormat("var x = {[a]: 1, b: 2, [c]: 3};"); verifyFormat("var x = {\n" " [a]: 1,\n" + " b: 2,\n" + " [c]: 3,\n" "};"); }