forked from OSchip/llvm-project
clang-format: [JS] Fix incorrect line break leading to semicolon insertion.
clang-format only works for JavaScript code, if all the semicolons are present anyway, so this linebreak can never be desired. Before (with appropriate statement lengths or column limit): return [ aaa ]; After: return [ aaaa ]; llvm-svn: 257741
This commit is contained in:
parent
c040ad5fde
commit
11a876533e
|
@ -2268,6 +2268,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
|
|||
Keywords.kw_implements))
|
||||
return true;
|
||||
} else if (Style.Language == FormatStyle::LK_JavaScript) {
|
||||
if (Left.is(tok::kw_return))
|
||||
return false; // Otherwise a semicolon is inserted.
|
||||
if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
|
||||
return false;
|
||||
if (Left.is(TT_JsTypeColon))
|
||||
|
|
|
@ -591,6 +591,10 @@ TEST_F(FormatTestJS, AutomaticSemicolonInsertion) {
|
|||
verifyFormat("throw aaaaa;", getGoogleJSStyleWithColumns(10));
|
||||
verifyFormat("aaaaaaaaa++;", getGoogleJSStyleWithColumns(10));
|
||||
verifyFormat("aaaaaaaaa--;", getGoogleJSStyleWithColumns(10));
|
||||
verifyFormat("return [\n"
|
||||
" aaa\n"
|
||||
"];",
|
||||
getGoogleJSStyleWithColumns(12));
|
||||
}
|
||||
|
||||
TEST_F(FormatTestJS, ClosureStyleCasts) {
|
||||
|
|
Loading…
Reference in New Issue