Skip to content

Commit 34970d8

Browse files
author
Benjamin Lichtman
committed
give jsdoc outline span before func exp assigned to var
1 parent d3bcb82 commit 34970d8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/services/outliningElementsCollector.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ namespace ts.OutliningElementsCollector {
3737
addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out);
3838
}
3939

40+
if (isFunctionExpressionAssignedToVariable(n)) {
41+
addOutliningForLeadingCommentsForNode(n.parent.parent.parent, sourceFile, cancellationToken, out);
42+
}
43+
4044
const span = getOutliningSpanForNode(n, sourceFile);
4145
if (span) out.push(span);
4246

@@ -54,6 +58,12 @@ namespace ts.OutliningElementsCollector {
5458
}
5559
depthRemaining++;
5660
}
61+
62+
function isFunctionExpressionAssignedToVariable(n: Node) {
63+
return (isFunctionExpression(n) || isArrowFunction(n)) &&
64+
n.parent && n.parent.parent && n.parent.parent.parent &&
65+
isVariableStatement(n.parent.parent.parent);
66+
}
5767
}
5868

5969
function addRegionOutliningSpans(sourceFile: SourceFile, out: Push<OutliningSpan>): void {

0 commit comments

Comments
 (0)