Skip to content

Commit 221ac50

Browse files
Merge pull request microsoft#23437 from Microsoft/getOutliningSpansDepthElseIf
In outliningElementsCollector, treat 'else if' as having same depth as the 'if'
2 parents cae4640 + a60caba commit 221ac50

File tree

2 files changed

+100
-1
lines changed

2 files changed

+100
-1
lines changed

src/services/outliningElementsCollector.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,17 @@ namespace ts.OutliningElementsCollector {
2121
if (span) out.push(span);
2222

2323
depthRemaining--;
24-
n.forEachChild(walk);
24+
if (isIfStatement(n) && isIfStatement(n.elseStatement)) {
25+
// Consider an 'else if' to be on the same depth as the 'if'.
26+
walk(n.expression);
27+
walk(n.thenStatement);
28+
depthRemaining++;
29+
walk(n.elseStatement);
30+
depthRemaining--;
31+
}
32+
else {
33+
n.forEachChild(walk);
34+
}
2535
depthRemaining++;
2636
});
2737
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
// Tests that each 'else if' does not count towards a higher nesting depth.
4+
5+
////if (1)[| {
6+
//// 1;
7+
////}|] else if (1)[| {
8+
//// 1;
9+
////}|] else if (1)[| {
10+
//// 1;
11+
////}|] else if (1)[| {
12+
//// 1;
13+
////}|] else if (1)[| {
14+
//// 1;
15+
////}|] else if (1)[| {
16+
//// 1;
17+
////}|] else if (1)[| {
18+
//// 1;
19+
////}|] else if (1)[| {
20+
//// 1;
21+
////}|] else if (1)[| {
22+
//// 1;
23+
////}|] else if (1)[| {
24+
//// 1;
25+
////}|] else if (1)[| {
26+
//// 1;
27+
////}|] else if (1)[| {
28+
//// 1;
29+
////}|] else if (1)[| {
30+
//// 1;
31+
////}|] else if (1)[| {
32+
//// 1;
33+
////}|] else if (1)[| {
34+
//// 1;
35+
////}|] else if (1)[| {
36+
//// 1;
37+
////}|] else if (1)[| {
38+
//// 1;
39+
////}|] else if (1)[| {
40+
//// 1;
41+
////}|] else if (1)[| {
42+
//// 1;
43+
////}|] else if (1)[| {
44+
//// 1;
45+
////}|] else if (1)[| {
46+
//// 1;
47+
////}|] else if (1)[| {
48+
//// 1;
49+
////}|] else if (1)[| {
50+
//// 1;
51+
////}|] else if (1)[| {
52+
//// 1;
53+
////}|] else if (1)[| {
54+
//// 1;
55+
////}|] else if (1)[| {
56+
//// 1;
57+
////}|] else if (1)[| {
58+
//// 1;
59+
////}|] else if (1)[| {
60+
//// 1;
61+
////}|] else if (1)[| {
62+
//// 1;
63+
////}|] else if (1)[| {
64+
//// 1;
65+
////}|] else if (1)[| {
66+
//// 1;
67+
////}|] else if (1)[| {
68+
//// 1;
69+
////}|] else if (1)[| {
70+
//// 1;
71+
////}|] else if (1)[| {
72+
//// 1;
73+
////}|] else if (1)[| {
74+
//// 1;
75+
////}|] else if (1)[| {
76+
//// 1;
77+
////}|] else if (1)[| {
78+
//// 1;
79+
////}|] else if (1)[| {
80+
//// 1;
81+
////}|] else if (1)[| {
82+
//// 1;
83+
////}|] else if (1)[| {
84+
//// 1;
85+
////}|] else[| {
86+
//// 1;
87+
////}|]
88+
89+
verify.outliningSpansInCurrentFile(test.ranges());

0 commit comments

Comments
 (0)