Skip to content

Commit 839fb8e

Browse files
committed
Fix recomputeIndentation
1 parent 6e272f3 commit 839fb8e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/services/formatting/formatting.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,8 @@ namespace ts.formatting {
565565
!suppressDelta && shouldAddDelta(line, kind, container) ? indentation + getDelta(container) : indentation,
566566
getIndentation: () => indentation,
567567
getDelta,
568-
recomputeIndentation: (lineAdded, parentIn) => {
569-
const parent = node.parent || parentIn;
570-
if (node !== parent && SmartIndenter.shouldIndentChildNode(options, parent, node, sourceFile)) {
568+
recomputeIndentation: (lineAdded, parent) => {
569+
if (SmartIndenter.shouldIndentChildNode(options, parent, node, sourceFile)) {
571570
indentation += lineAdded ? options.indentSize! : -options.indentSize!;
572571
delta = SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize! : 0;
573572
}
@@ -992,15 +991,15 @@ namespace ts.formatting {
992991
// Handle the case where the next line is moved to be the end of this line.
993992
// In this case we don't indent the next line in the next pass.
994993
if (currentParent.getStart(sourceFile) === currentItem.pos) {
995-
dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, currentParent);
994+
dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode);
996995
}
997996
break;
998997
case LineAction.LineAdded:
999998
// Handle the case where token2 is moved to the new line.
1000999
// In this case we indent token2 in the next pass but we set
10011000
// sameLineIndent flag to notify the indenter that the indentation is within the line.
10021001
if (currentParent.getStart(sourceFile) === currentItem.pos) {
1003-
dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true, currentParent);
1002+
dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true, contextNode);
10041003
}
10051004
break;
10061005
default:

0 commit comments

Comments
 (0)