Merge pull request #38656 from a-tarasyuk/bug/33233

fix(33233): Code Folding on es5 object functions does not work (getOutliningSpans)
This commit is contained in:
Nathan Shively-Sanders
2020-05-19 14:18:42 -07:00
committed by GitHub
3 changed files with 36 additions and 0 deletions
@@ -42,6 +42,10 @@ namespace ts.OutliningElementsCollector {
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);
}
const span = getOutliningSpanForNode(n, sourceFile);
if (span) out.push(span);
@@ -110,6 +110,26 @@
//// const sum2 = (y, z) =>[| {
//// return y + z;
//// }|];
////
////function Foo()[| {
//// [|/**
//// * Description
//// *
//// * @param {string} param
//// * @returns
//// */|]
//// this.method = function (param)[| {
//// }|]
////
//// [|/**
//// * Description
//// *
//// * @param {string} param
//// * @returns
//// */|]
//// function method(param)[| {
//// }|]
////}|]
verify.outliningSpansInCurrentFile(test.ranges());
@@ -72,6 +72,18 @@
////// One single line comment should not be collapsed
////class WithOneSingleLineComment[| {
////}|]
////
////function Foo()[| {
//// [|// comment 1
//// // comment 2|]
//// this.method = function (param)[| {
//// }|]
////
//// [|// comment 1
//// // comment 2|]
//// function method(param)[| {
//// }|]
////}|]
verify.outliningSpansInCurrentFile(test.ranges());