Skip to content

Commit a39a675

Browse files
a-tarasyukDanielRosenwasser
authored andcommitted
fix(35474): formatter incorrectly adds space after increment (#35550)
1 parent 05a2f1b commit a39a675

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/services/formatting/rules.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,9 @@ namespace ts.formatting {
433433
}
434434

435435
function isBinaryOpContext(context: FormattingContext): boolean {
436-
437436
switch (context.contextNode.kind) {
438437
case SyntaxKind.BinaryExpression:
438+
return (<BinaryExpression>context.contextNode).operatorToken.kind !== SyntaxKind.CommaToken;
439439
case SyntaxKind.ConditionalExpression:
440440
case SyntaxKind.ConditionalType:
441441
case SyntaxKind.AsExpression:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
////let i = 0;
4+
/////*1*/(i++,i++);
5+
/////*2*/(i++,++i);
6+
/////*3*/(1,2);
7+
/////*4*/(i++,2);
8+
/////*5*/(i++,i++,++i,i--,2);
9+
10+
////let s = 'foo';
11+
/////*6*/for (var i = 0,ii = 2; i < s.length; ii++,i++) {
12+
////}
13+
14+
format.document();
15+
16+
goTo.marker("1");
17+
verify.currentLineContentIs(`(i++, i++);`);
18+
19+
goTo.marker("2");
20+
verify.currentLineContentIs(`(i++, ++i);`);
21+
22+
goTo.marker("3");
23+
verify.currentLineContentIs(`(1, 2);`);
24+
25+
goTo.marker("4");
26+
verify.currentLineContentIs(`(i++, 2);`);
27+
28+
goTo.marker("5");
29+
verify.currentLineContentIs(`(i++, i++, ++i, i--, 2);`);
30+
31+
goTo.marker("6");
32+
verify.currentLineContentIs(`for (var i = 0, ii = 2; i < s.length; ii++, i++) {`);

0 commit comments

Comments
 (0)