Skip to content

Commit 415b2e7

Browse files
authored
Merge pull request microsoft#38656 from a-tarasyuk/bug/33233
fix(33233): Code Folding on es5 object functions does not work (getOutliningSpans)
2 parents c5cca0e + 2b703d2 commit 415b2e7

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/services/outliningElementsCollector.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ namespace ts.OutliningElementsCollector {
4242
addOutliningForLeadingCommentsForNode(n.parent.parent.parent, sourceFile, cancellationToken, out);
4343
}
4444

45+
if (isFunctionLike(n) && isBinaryExpression(n.parent) && isPropertyAccessExpression(n.parent.left)) {
46+
addOutliningForLeadingCommentsForNode(n.parent.left, sourceFile, cancellationToken, out);
47+
}
48+
4549
const span = getOutliningSpanForNode(n, sourceFile);
4650
if (span) out.push(span);
4751

tests/cases/fourslash/getOutliningForBlockComments.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,26 @@
110110
//// const sum2 = (y, z) =>[| {
111111
//// return y + z;
112112
//// }|];
113+
////
114+
////function Foo()[| {
115+
//// [|/**
116+
//// * Description
117+
//// *
118+
//// * @param {string} param
119+
//// * @returns
120+
//// */|]
121+
//// this.method = function (param)[| {
122+
//// }|]
123+
////
124+
//// [|/**
125+
//// * Description
126+
//// *
127+
//// * @param {string} param
128+
//// * @returns
129+
//// */|]
130+
//// function method(param)[| {
131+
//// }|]
132+
////}|]
113133

114134
verify.outliningSpansInCurrentFile(test.ranges());
115135

tests/cases/fourslash/getOutliningForSingleLineComments.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@
7272
////// One single line comment should not be collapsed
7373
////class WithOneSingleLineComment[| {
7474
////}|]
75+
////
76+
////function Foo()[| {
77+
//// [|// comment 1
78+
//// // comment 2|]
79+
//// this.method = function (param)[| {
80+
//// }|]
81+
////
82+
//// [|// comment 1
83+
//// // comment 2|]
84+
//// function method(param)[| {
85+
//// }|]
86+
////}|]
7587

7688
verify.outliningSpansInCurrentFile(test.ranges());
7789

0 commit comments

Comments
 (0)