From 92bd16fea4d2ec73c062576c69a1ecbc26b4ab21 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 20 Nov 2015 16:44:28 +0000 Subject: [PATCH] clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty" work properly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253674 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 1 + unittests/Format/FormatTestJS.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 171ecc41d7..5aa4dadb55 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -2104,6 +2104,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, !Left.Children.empty()) // Support AllowShortFunctionsOnASingleLine for JavaScript. return Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_None || + Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Empty || (Left.NestingLevel == 0 && Line.Level == 0 && Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Inline); diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 56a91442f9..d9b90ded15 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -448,6 +448,12 @@ TEST_F(FormatTestJS, InliningFunctionLiterals) { " }\n" "}", Style); + + Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty; + verifyFormat("var func = function() {\n" + " return 1;\n" + "};", + Style); } TEST_F(FormatTestJS, MultipleFunctionLiterals) { -- 2.40.0