Skip to content

Commit 0e7a989

Browse files
author
Andy Hanson
committed
Use depthRemaining instead of maxDepth
1 parent b0d71b8 commit 0e7a989

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

src/services/outliningElementsCollector.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ namespace ts.OutliningElementsCollector {
88
}
99

1010
function addNodeOutliningSpans(sourceFile: SourceFile, cancellationToken: CancellationToken, out: Push<OutliningSpan>): void {
11-
let depth = 0;
12-
const maxDepth = 39;
11+
let depthRemaining = 40;
1312
sourceFile.forEachChild(function walk(n) {
14-
if (depth > maxDepth) return;
13+
if (depthRemaining === 0) return;
1514
cancellationToken.throwIfCancellationRequested();
1615

1716
if (isDeclaration(n)) {
@@ -21,9 +20,9 @@ namespace ts.OutliningElementsCollector {
2120
const span = getOutliningSpanForNode(n, sourceFile);
2221
if (span) out.push(span);
2322

24-
depth++;
23+
depthRemaining--;
2524
n.forEachChild(walk);
26-
depth--;
25+
depthRemaining++;
2726
});
2827
}
2928

tests/cases/fourslash/getOutliningSpans.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference path="fourslash.ts"/>
22

3-
////// interface
3+
////// interface
44
////interface IFoo[| {
55
//// getDist(): number;
66
////}|]
@@ -63,9 +63,9 @@
6363
////}|])
6464
////
6565
////// trivia handeling
66-
////class ClassFooWithTrivia[| /* some comments */
66+
////class ClassFooWithTrivia[| /* some comments */
6767
//// /* more trivia */ {
68-
////
68+
////
6969
////
7070
//// /*some trailing trivia */
7171
////}|] /* even more */
@@ -85,8 +85,8 @@
8585
//// [
8686
//// [
8787
//// [
88-
//// 1,2,3
89-
//// ]
88+
//// 1,2,3
89+
//// ]
9090
//// ]
9191
//// ]
9292
//// ]

tests/cases/fourslash/shims-pp/getOutliningSpans.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference path="fourslash.ts"/>
22

3-
////// interface
3+
////// interface
44
////interface IFoo[| {
55
//// getDist(): number;
66
////}|]
@@ -63,9 +63,9 @@
6363
////}|])
6464
////
6565
////// trivia handeling
66-
////class ClassFooWithTrivia[| /* some comments */
66+
////class ClassFooWithTrivia[| /* some comments */
6767
//// /* more trivia */ {
68-
////
68+
////
6969
////
7070
//// /*some trailing trivia */
7171
////}|] /* even more */
@@ -85,8 +85,8 @@
8585
//// [
8686
//// [
8787
//// [
88-
//// 1,2,3
89-
//// ]
88+
//// 1,2,3
89+
//// ]
9090
//// ]
9191
//// ]
9292
//// ]

tests/cases/fourslash/shims/getOutliningSpans.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference path="fourslash.ts"/>
22

3-
////// interface
3+
////// interface
44
////interface IFoo[| {
55
//// getDist(): number;
66
////}|]
@@ -63,9 +63,9 @@
6363
////}|])
6464
////
6565
////// trivia handeling
66-
////class ClassFooWithTrivia[| /* some comments */
66+
////class ClassFooWithTrivia[| /* some comments */
6767
//// /* more trivia */ {
68-
////
68+
////
6969
////
7070
//// /*some trailing trivia */
7171
////}|] /* even more */
@@ -85,8 +85,8 @@
8585
//// [
8686
//// [
8787
//// [
88-
//// 1,2,3
89-
//// ]
88+
//// 1,2,3
89+
//// ]
9090
//// ]
9191
//// ]
9292
//// ]

0 commit comments

Comments
 (0)