mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-14 18:39:19 -05:00
remove space after close bracket only if next token does not start block in function declaration context
This commit is contained in:
@@ -231,7 +231,7 @@ module ts.formatting {
|
||||
this.NoSpaceBeforeOpenBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete));
|
||||
|
||||
// Place a space before open brace in a function declaration
|
||||
this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments;
|
||||
@@ -650,6 +650,10 @@ module ts.formatting {
|
||||
return context.TokensAreOnSameLine();
|
||||
}
|
||||
|
||||
static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean {
|
||||
return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context)
|
||||
}
|
||||
|
||||
static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean {
|
||||
return context.TokensAreOnSameLine() &&
|
||||
context.contextNode.decorators &&
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
/////*0*/function listAPIFiles(path: string): string[] {/*1*/ }
|
||||
|
||||
goTo.marker("1");
|
||||
edit.insertLine("");
|
||||
goTo.marker("0");
|
||||
verify.currentLineContentIs("function listAPIFiles(path: string): string[] {");
|
||||
Reference in New Issue
Block a user