summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp1
2 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 635092dec39..f5a33d4ddf2 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2001,8 +2001,9 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow,
Keywords.kw_in))
return true;
- if (Left.is(tok::kw_default) && Right.is(TT_ArrayInitializerLSquare))
- return true; // For "export default [];".
+ if (Left.is(tok::kw_default) && Left.Previous &&
+ Left.Previous->is(tok::kw_export))
+ return true;
if (Left.is(Keywords.kw_is) && Right.is(tok::l_brace))
return true;
if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 0013e83ddd6..2f67bdf549c 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -870,6 +870,7 @@ TEST_F(FormatTestJS, Modules) {
" bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n"
"];");
verifyFormat("export default [];");
+ verifyFormat("export default () => {};");
}
TEST_F(FormatTestJS, TemplateStrings) {
OpenPOWER on IntegriCloud