Skip to content

Commit 35ca82c

Browse files
committed
Merge pull request #3738 from SaschaNaz/parenIndentFix
Fixing indentation of dangling closing parenthesis
2 parents 965f994 + b402b63 commit 35ca82c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/services/formatting/formatting.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ namespace ts.formatting {
480480
case SyntaxKind.CloseBraceToken:
481481
case SyntaxKind.OpenBracketToken:
482482
case SyntaxKind.CloseBracketToken:
483+
case SyntaxKind.OpenParenToken:
484+
case SyntaxKind.CloseParenToken:
483485
case SyntaxKind.ElseKeyword:
484486
case SyntaxKind.WhileKeyword:
485487
case SyntaxKind.AtToken:
@@ -644,7 +646,7 @@ namespace ts.formatting {
644646
// consume list start token
645647
startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
646648
let indentation =
647-
computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, startLine);
649+
computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, parentStartLine);
648650

649651
listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation.indentation, indentation.delta);
650652
consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation);

tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ goTo.marker("1");
1818
edit.insert("\r\n");
1919
goTo.marker("0");
2020
// Won't-fixed: Smart indent during chained function calls
21-
verify.indentationIs(8);
21+
verify.indentationIs(4);

tests/cases/fourslash/functionIndentation.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ verify.currentFileContentIs(
4646
" C;\n" +
4747
" class C {\n" +
4848
" constructor(b\n" +
49-
" ) {\n" +
49+
" ) {\n" +
5050
" }\n" +
5151
" foo(a\n" +
5252
" : string) {\n" +
5353
" return a\n" +
5454
" || true;\n" +
5555
" }\n" +
5656
" get bar(\n" +
57-
" ) {\n" +
57+
" ) {\n" +
5858
" return 1;\n" +
5959
" }\n" +
6060
" }\n" +

0 commit comments

Comments
 (0)