mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
fix(35474): formatter incorrectly adds space after increment (#35550)
This commit is contained in:
parent
05a2f1b110
commit
a39a675696
@ -433,9 +433,9 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function isBinaryOpContext(context: FormattingContext): boolean {
|
||||
|
||||
switch (context.contextNode.kind) {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return (<BinaryExpression>context.contextNode).operatorToken.kind !== SyntaxKind.CommaToken;
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
case SyntaxKind.ConditionalType:
|
||||
case SyntaxKind.AsExpression:
|
||||
|
||||
32
tests/cases/fourslash/spaceBeforeAndAfterBinaryOperators.ts
Normal file
32
tests/cases/fourslash/spaceBeforeAndAfterBinaryOperators.ts
Normal file
@ -0,0 +1,32 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////let i = 0;
|
||||
/////*1*/(i++,i++);
|
||||
/////*2*/(i++,++i);
|
||||
/////*3*/(1,2);
|
||||
/////*4*/(i++,2);
|
||||
/////*5*/(i++,i++,++i,i--,2);
|
||||
|
||||
////let s = 'foo';
|
||||
/////*6*/for (var i = 0,ii = 2; i < s.length; ii++,i++) {
|
||||
////}
|
||||
|
||||
format.document();
|
||||
|
||||
goTo.marker("1");
|
||||
verify.currentLineContentIs(`(i++, i++);`);
|
||||
|
||||
goTo.marker("2");
|
||||
verify.currentLineContentIs(`(i++, ++i);`);
|
||||
|
||||
goTo.marker("3");
|
||||
verify.currentLineContentIs(`(1, 2);`);
|
||||
|
||||
goTo.marker("4");
|
||||
verify.currentLineContentIs(`(i++, 2);`);
|
||||
|
||||
goTo.marker("5");
|
||||
verify.currentLineContentIs(`(i++, i++, ++i, i--, 2);`);
|
||||
|
||||
goTo.marker("6");
|
||||
verify.currentLineContentIs(`for (var i = 0, ii = 2; i < s.length; ii++, i++) {`);
|
||||
Loading…
x
Reference in New Issue
Block a user