]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Fix spacing in destructuring assignments.
authorDaniel Jasper <djasper@google.com>
Thu, 19 May 2016 07:18:07 +0000 (07:18 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 19 May 2016 07:18:07 +0000 (07:18 +0000)
Before:
  const[a, b, c] = [1, 2, 3];

After:
  const [a, b, c] = [1, 2, 3];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270029 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJS.cpp

index bdf3dc3e57f612869c7631a4abe8cb5101c2366b..1713865ee5965cad5b327b0c723a5283c263dfd5 100644 (file)
@@ -2083,7 +2083,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
         Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
       return false;
     if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in,
-                     Keywords.kw_of) &&
+                     Keywords.kw_of, tok::kw_const) &&
         (!Left.Previous || !Left.Previous->is(tok::period)))
       return true;
     if (Left.is(tok::kw_default) && Left.Previous &&
index 485e8224c3206fcb30158e6015b805911b5d9ed3..5f60f1d2162bb67bb1e4e942247e45f355738b7b 100644 (file)
@@ -148,6 +148,7 @@ TEST_F(FormatTestJS, CppKeywords) {
 
 TEST_F(FormatTestJS, ES6DestructuringAssignment) {
   verifyFormat("var [a, b, c] = [1, 2, 3];");
+  verifyFormat("const [a, b, c] = [1, 2, 3];");
   verifyFormat("let [a, b, c] = [1, 2, 3];");
   verifyFormat("var {a, b} = {a: 1, b: 2};");
   verifyFormat("let {a, b} = {a: 1, b: 2};");