Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a39a675

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

2 files changed

+33-1Lines changed: 33 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/services/formatting/rules.ts‎

Copy file name to clipboardExpand all lines: src/services/formatting/rules.ts
+1-1Lines changed: 1 addition & 1 deletion
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:
Collapse file
+32Lines changed: 32 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.