clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"

work properly.

llvm-svn: 253674
This commit is contained in:
Daniel Jasper 2015-11-20 16:44:28 +00:00
parent 43db5b7daa
commit 71e574543f
2 changed files with 7 additions and 0 deletions

View File

@ -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);

View File

@ -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) {