Skip to content

Commit e26bc8a

Browse files
authored
Skip missing nodes in formatting (microsoft#48953)
1 parent f579f33 commit e26bc8a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/services/formatting/formatting.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,10 @@ namespace ts.formatting {
691691
isListItem: boolean,
692692
isFirstListItem?: boolean): number {
693693

694+
if (nodeIsMissing(child)) {
695+
return inheritedIndentation;
696+
}
697+
694698
const childStartPos = child.getStart(sourceFile);
695699

696700
const childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path="fourslash.ts" />
2+
// @Filename: foo.js
3+
//// function foo() {}
4+
//// /*1*/%PrepareFunctionForOptimization(foo)/*2*/;
5+
6+
// Don't really care what it does beyond not crashing
7+
format.selection("1", "2");

0 commit comments

Comments
 (0)