From: Daniel Jasper Date: Fri, 8 Jan 2016 10:51:24 +0000 (+0000) Subject: clang-format: [JS] Prefer wrapping before the TypeScript return type X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33683e50365f7ef6dc81b5d9d25b609b6899b3c0;p=clang clang-format: [JS] Prefer wrapping before the TypeScript return type over wrapping before parameters. Before: function someFunc( args: string[]): {longReturnValue: string[]} {} After: function someFunc(args: string[]): {longReturnValue: string[]} {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257162 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 7390865d4c..b6145a9935 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1725,7 +1725,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, if (Right.is(Keywords.kw_function) && Left.isNot(tok::comma)) return 100; if (Left.is(TT_JsTypeColon)) - return 100; + return 35; } if (Left.is(tok::comma) || (Right.is(tok::identifier) && Right.Next && diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 4600d7feb3..7514c43ad4 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -740,6 +740,9 @@ TEST_F(FormatTestJS, TypeAnnotations) { verifyFormat("var x: P string>;"); verifyFormat("var x = {y: function(): z { return 1; }};"); verifyFormat("var x = {y: function(): {a: number} { return 1; }};"); + verifyFormat("function someFunc(args: string[]):\n" + " {longReturnValue: string[]} {}", + getGoogleJSStyleWithColumns(60)); } TEST_F(FormatTestJS, ClassDeclarations) {