Skip to content

Commit

Permalink
Merge pull request microsoft#38656 from a-tarasyuk/bug/33233
Browse files Browse the repository at this point in the history
fix(33233): Code Folding on es5 object functions does not work (getOutliningSpans)
  • Loading branch information
sandersn committed May 19, 2020
2 parents c5cca0e + 2b703d2 commit 415b2e7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/services/outliningElementsCollector.ts
Expand Up @@ -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);

Expand Down
20 changes: 20 additions & 0 deletions tests/cases/fourslash/getOutliningForBlockComments.ts
Expand Up @@ -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());

Expand Down
12 changes: 12 additions & 0 deletions tests/cases/fourslash/getOutliningForSingleLineComments.ts
Expand Up @@ -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());

Expand Down

0 comments on commit 415b2e7

Please sign in to comment.