mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-11 09:24:19 -06:00
Just add a trailing call to visitNode instead of creating a new array when collecting outlining spans (#61987)
This commit is contained in:
parent
441655c270
commit
fe698aef28
@ -67,8 +67,7 @@ export function collectElements(sourceFile: SourceFile, cancellationToken: Cance
|
||||
function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: CancellationToken, out: OutliningSpan[]): void {
|
||||
let depthRemaining = 40;
|
||||
let current = 0;
|
||||
// Includes the EOF Token so that comments which aren't attached to statements are included
|
||||
const statements = [...sourceFile.statements, sourceFile.endOfFileToken];
|
||||
const statements = sourceFile.statements;
|
||||
const n = statements.length;
|
||||
while (current < n) {
|
||||
while (current < n && !isAnyImportSyntax(statements[current])) {
|
||||
@ -87,6 +86,9 @@ function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: Cancel
|
||||
}
|
||||
}
|
||||
|
||||
// Visit the EOF Token so that comments which aren't attached to statements are included.
|
||||
visitNode(sourceFile.endOfFileToken);
|
||||
|
||||
function visitNode(n: Node) {
|
||||
if (depthRemaining === 0) return;
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user