fix(40010): add outlining for comments before variables statements (#40016)
This commit is contained in:
parent
27eb8628e5
commit
fa5e9807e8
|
@ -34,14 +34,10 @@ namespace ts.OutliningElementsCollector {
|
|||
if (depthRemaining === 0) return;
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
if (isDeclaration(n) || n.kind === SyntaxKind.EndOfFileToken) {
|
||||
if (isDeclaration(n) || isVariableStatement(n) || n.kind === SyntaxKind.EndOfFileToken) {
|
||||
addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out);
|
||||
}
|
||||
|
||||
if (isFunctionExpressionAssignedToVariable(n)) {
|
||||
addOutliningForLeadingCommentsForNode(n.parent.parent.parent, sourceFile, cancellationToken, out);
|
||||
}
|
||||
|
||||
if (isFunctionLike(n) && isBinaryExpression(n.parent) && isPropertyAccessExpression(n.parent.left)) {
|
||||
addOutliningForLeadingCommentsForNode(n.parent.left, sourceFile, cancellationToken, out);
|
||||
}
|
||||
|
@ -70,14 +66,6 @@ namespace ts.OutliningElementsCollector {
|
|||
}
|
||||
depthRemaining++;
|
||||
}
|
||||
|
||||
function isFunctionExpressionAssignedToVariable(n: Node) {
|
||||
if (!isFunctionExpression(n) && !isArrowFunction(n)) {
|
||||
return false;
|
||||
}
|
||||
const ancestor = findAncestor(n, isVariableStatement);
|
||||
return !!ancestor && getSingleInitializerOfVariableStatementOrPropertyDeclaration(ancestor) === n;
|
||||
}
|
||||
}
|
||||
|
||||
function addRegionOutliningSpans(sourceFile: SourceFile, out: Push<OutliningSpan>): void {
|
||||
|
|
|
@ -111,6 +111,12 @@
|
|||
//// return y + z;
|
||||
//// }|];
|
||||
////
|
||||
////// Over a variable
|
||||
////[|/**
|
||||
//// * foo
|
||||
//// */|]
|
||||
////const foo = null;
|
||||
////
|
||||
////function Foo()[| {
|
||||
//// [|/**
|
||||
//// * Description
|
||||
|
|
Loading…
Reference in a new issue