mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
include binding element with initializer to current formatting rule for binary operator, adjust existing SpaceBeforeOpenBraceInFunction rule to recognize blocks
This commit is contained in:
parent
ea09299d1e
commit
b8a1712688
@ -239,7 +239,7 @@ module ts.formatting {
|
||||
|
||||
// Place a space before open brace in a function declaration
|
||||
this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments;
|
||||
this.SpaceBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines);
|
||||
this.SpaceBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines);
|
||||
|
||||
// Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc)
|
||||
this.TypeScriptOpenBraceLeftTokenRange = Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia]);
|
||||
@ -470,6 +470,8 @@ module ts.formatting {
|
||||
// Technically, "of" is not a binary operator, but format it the same way as "in"
|
||||
case SyntaxKind.ForOfStatement:
|
||||
return context.currentTokenSpan.kind === SyntaxKind.OfKeyword || context.nextTokenSpan.kind === SyntaxKind.OfKeyword;
|
||||
case SyntaxKind.BindingElement:
|
||||
return context.currentTokenSpan.kind === SyntaxKind.EqualsToken || context.nextTokenSpan.kind === SyntaxKind.EqualsToken;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
9
tests/cases/fourslash/formattingInDestructuring2.ts
Normal file
9
tests/cases/fourslash/formattingInDestructuring2.ts
Normal file
@ -0,0 +1,9 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
/////*1*/function drawText( { text = "", location: [x, y]= [0, 0], bold = false }) {
|
||||
//// // Draw text
|
||||
////}
|
||||
|
||||
format.document();
|
||||
goTo.marker("1");
|
||||
verify.currentLineContentIs("function drawText({ text = \"\", location: [x, y] = [0, 0], bold = false }) {");
|
||||
Loading…
x
Reference in New Issue
Block a user