Merge pull request #6394 from SaschaNaz/noSpaceBetweenCommaAndCB
Remove space between comma and close bracket
This commit is contained in:
commit
14b39490a5
|
@ -444,7 +444,7 @@ namespace ts.formatting {
|
|||
///
|
||||
|
||||
// Insert space after comma delimiter
|
||||
this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space));
|
||||
this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Insert space before and after binary operators
|
||||
|
@ -711,6 +711,10 @@ namespace ts.formatting {
|
|||
return context.currentTokenSpan.kind !== SyntaxKind.CommaToken;
|
||||
}
|
||||
|
||||
static IsNextTokenNotCloseBracket(context: FormattingContext): boolean {
|
||||
return context.nextTokenSpan.kind !== SyntaxKind.CloseBracketToken;
|
||||
}
|
||||
|
||||
static IsArrowFunctionContext(context: FormattingContext): boolean {
|
||||
return context.contextNode.kind === SyntaxKind.ArrowFunction;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
///<reference path="fourslash.ts"/>
|
||||
|
||||
/////*InsertSpaceAfterCommaDelimiter*/[1,2, 3];
|
||||
/////*InsertSpaceAfterCommaDelimiter*/[1,2, 3];[ 72 , ];
|
||||
/////*InsertSpaceAfterSemicolonInForStatements*/for (i = 0;i; i++);
|
||||
/////*InsertSpaceBeforeAndAfterBinaryOperators*/1+2- 3
|
||||
/////*InsertSpaceAfterKeywordsInControlFlowStatements*/if (true) { }
|
||||
|
@ -13,13 +13,13 @@
|
|||
/////*PlaceOpenBraceOnNewLineForControlBlocks*/if (true) {
|
||||
////}
|
||||
|
||||
runTest("InsertSpaceAfterCommaDelimiter", "[1, 2, 3];", "[1,2,3];");
|
||||
runTest("InsertSpaceAfterCommaDelimiter", "[1, 2, 3];[72,];", "[1,2,3];[72,];");
|
||||
runTest("InsertSpaceAfterSemicolonInForStatements", "for (i = 0; i; i++);", "for (i = 0;i;i++);");
|
||||
runTest("InsertSpaceBeforeAndAfterBinaryOperators", "1 + 2 - 3", "1+2-3");
|
||||
runTest("InsertSpaceAfterKeywordsInControlFlowStatements", "if (true) { }", "if(true) { }");
|
||||
runTest("InsertSpaceAfterFunctionKeywordForAnonymousFunctions", "(function () { })", "(function() { })");
|
||||
runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis", " ( 1 )", " (1)");
|
||||
runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", "[ 1 ];[];[];[ , ];", "[1];[];[];[, ];");
|
||||
runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", "[ 1 ];[];[];[ , ];", "[1];[];[];[,];");
|
||||
runTest("InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }`; `${ 1 }`", "`${1}`; `${1}`");
|
||||
runTest("PlaceOpenBraceOnNewLineForFunctions", "class foo", "class foo {");
|
||||
runTest("PlaceOpenBraceOnNewLineForControlBlocks", "if ( true )", "if ( true ) {");
|
||||
|
|
Loading…
Reference in a new issue