mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 23:08:20 -06:00
Merge pull request #30743 from andrewbranch/bug/30675
Make anonymous function formatting apply to anonymous generators too
This commit is contained in:
commit
cd56398a53
@ -98,7 +98,7 @@ namespace ts.formatting {
|
||||
rule("SpaceAfterConditionalClosingParen", SyntaxKind.CloseParenToken, SyntaxKind.OpenBracketToken, [isControlDeclContext], RuleAction.Space),
|
||||
|
||||
rule("NoSpaceBetweenFunctionKeywordAndStar", SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken, [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.Delete),
|
||||
rule("SpaceAfterStarInGeneratorDeclaration", SyntaxKind.AsteriskToken, [SyntaxKind.Identifier, SyntaxKind.OpenParenToken], [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.Space),
|
||||
rule("SpaceAfterStarInGeneratorDeclaration", SyntaxKind.AsteriskToken, SyntaxKind.Identifier, [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.Space),
|
||||
|
||||
rule("SpaceAfterFunctionInFuncDecl", SyntaxKind.FunctionKeyword, anyToken, [isFunctionDeclContext], RuleAction.Space),
|
||||
// Insert new line after { and before } in multi-line contexts.
|
||||
@ -241,8 +241,8 @@ namespace ts.formatting {
|
||||
rule("NoSpaceAfterComma", SyntaxKind.CommaToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], RuleAction.Delete),
|
||||
|
||||
// Insert space after function keyword for anonymous functions
|
||||
rule("SpaceAfterAnonymousFunctionKeyword", SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], RuleAction.Space),
|
||||
rule("NoSpaceAfterAnonymousFunctionKeyword", SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], RuleAction.Delete),
|
||||
rule("SpaceAfterAnonymousFunctionKeyword", [SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken], SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], RuleAction.Space),
|
||||
rule("NoSpaceAfterAnonymousFunctionKeyword", [SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken], SyntaxKind.OpenParenToken, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], RuleAction.Delete),
|
||||
|
||||
// Insert space after keywords in control flow statements
|
||||
rule("SpaceAfterKeywordInControl", keywords, SyntaxKind.OpenParenToken, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], RuleAction.Space),
|
||||
|
||||
@ -5,9 +5,11 @@
|
||||
/////*3*/var bar = function foo() { };
|
||||
/////*4*/var foo = { bar() { } };
|
||||
/////*5*/function tmpl <T> () { }
|
||||
/////*6*/var f = function*() { };
|
||||
/////*7*/function* g () { }
|
||||
|
||||
format.setOption("InsertSpaceBeforeFunctionParenthesis", true);
|
||||
|
||||
format.setOption("insertSpaceBeforeFunctionParenthesis", true);
|
||||
format.setOption("insertSpaceAfterFunctionKeywordForAnonymousFunctions", false);
|
||||
format.document();
|
||||
|
||||
goTo.marker('1');
|
||||
@ -20,3 +22,7 @@ goTo.marker('4');
|
||||
verify.currentLineContentIs('var foo = { bar () { } };');
|
||||
goTo.marker('5');
|
||||
verify.currentLineContentIs('function tmpl<T> () { }');
|
||||
goTo.marker('6');
|
||||
verify.currentLineContentIs('var f = function*() { };');
|
||||
goTo.marker('7');
|
||||
verify.currentLineContentIs('function* g () { }');
|
||||
|
||||
@ -7,4 +7,4 @@ format.document();
|
||||
goTo.marker('1');
|
||||
verify.currentLineContentIs("function* g() { }");
|
||||
goTo.marker('2');
|
||||
verify.currentLineContentIs("var v = function* () { };");
|
||||
verify.currentLineContentIs("var v = function*() { };");
|
||||
Loading…
x
Reference in New Issue
Block a user