mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-18 13:59:04 -05:00
Adds floating block comments to the outlining spans response (#36880)
* Adds floating block comments to the outlining spans response * Only use one route for grabbing outline nodes, which now includes special casing the EOF token
This commit is contained in:
@@ -10,7 +10,8 @@ namespace ts.OutliningElementsCollector {
|
||||
function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: CancellationToken, out: Push<OutliningSpan>): void {
|
||||
let depthRemaining = 40;
|
||||
let current = 0;
|
||||
const statements = sourceFile.statements;
|
||||
// Includes the EOF Token so that comments which aren't attached to statements are included
|
||||
const statements = [...sourceFile.statements, sourceFile.endOfFileToken];
|
||||
const n = statements.length;
|
||||
while (current < n) {
|
||||
while (current < n && !isAnyImportSyntax(statements[current])) {
|
||||
@@ -33,7 +34,7 @@ namespace ts.OutliningElementsCollector {
|
||||
if (depthRemaining === 0) return;
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
if (isDeclaration(n)) {
|
||||
if (isDeclaration(n) || n.kind === SyntaxKind.EndOfFileToken) {
|
||||
addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user