Skip to content

Commit fe698ae

Browse files
Just add a trailing call to visitNode instead of creating a new array when collecting outlining spans (#61987)
1 parent 441655c commit fe698ae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/services/outliningElementsCollector.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ export function collectElements(sourceFile: SourceFile, cancellationToken: Cance
6767
function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: CancellationToken, out: OutliningSpan[]): void {
6868
let depthRemaining = 40;
6969
let current = 0;
70-
// Includes the EOF Token so that comments which aren't attached to statements are included
71-
const statements = [...sourceFile.statements, sourceFile.endOfFileToken];
70+
const statements = sourceFile.statements;
7271
const n = statements.length;
7372
while (current < n) {
7473
while (current < n && !isAnyImportSyntax(statements[current])) {
@@ -87,6 +86,9 @@ function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: Cancel
8786
}
8887
}
8988

89+
// Visit the EOF Token so that comments which aren't attached to statements are included.
90+
visitNode(sourceFile.endOfFileToken);
91+
9092
function visitNode(n: Node) {
9193
if (depthRemaining === 0) return;
9294
cancellationToken.throwIfCancellationRequested();

0 commit comments

Comments
 (0)