summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp2
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp3
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 3b6628ecfbd..ad40d99ad82 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 d95ff9ba834..29b8aa1ff13 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"
"};");
}
OpenPOWER on IntegriCloud