diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 5e3ab31c46a..3f4d345be8c 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -37,6 +37,10 @@ namespace ts.OutliningElementsCollector { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } + if (isFunctionExpressionAssignedToVariable(n)) { + addOutliningForLeadingCommentsForNode(n.parent.parent.parent, sourceFile, cancellationToken, out); + } + const span = getOutliningSpanForNode(n, sourceFile); if (span) out.push(span); @@ -54,6 +58,12 @@ namespace ts.OutliningElementsCollector { } depthRemaining++; } + + function isFunctionExpressionAssignedToVariable(n: Node) { + return (isFunctionExpression(n) || isArrowFunction(n)) && + n.parent && n.parent.parent && n.parent.parent.parent && + isVariableStatement(n.parent.parent.parent); + } } function addRegionOutliningSpans(sourceFile: SourceFile, out: Push): void {