From 76a6b3e0e1e6dc805aa670d42142ae2bd5008967 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 19 May 2016 07:18:07 +0000 Subject: [PATCH] clang-format: [JS] Fix spacing in destructuring assignments. 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 | 2 +- unittests/Format/FormatTestJS.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index bdf3dc3e57..1713865ee5 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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 && diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 485e8224c3..5f60f1d216 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -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};"); -- 2.40.0