In outliningElementsCollector, treat 'else if' as having same depth as the 'if'

This commit is contained in:
Andy Hanson 2018-04-16 11:22:24 -07:00
parent cc6bc763bc
commit a60caba467
2 changed files with 100 additions and 1 deletions

View file

@ -21,7 +21,17 @@ namespace ts.OutliningElementsCollector {
if (span) out.push(span);
depthRemaining--;
n.forEachChild(walk);
if (isIfStatement(n) && isIfStatement(n.elseStatement)) {
// Consider an 'else if' to be on the same depth as the 'if'.
walk(n.expression);
walk(n.thenStatement);
depthRemaining++;
walk(n.elseStatement);
depthRemaining--;
}
else {
n.forEachChild(walk);
}
depthRemaining++;
});
}

View file

@ -0,0 +1,89 @@
/// <reference path="fourslash.ts"/>
// Tests that each 'else if' does not count towards a higher nesting depth.
////if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else if (1)[| {
//// 1;
////}|] else[| {
//// 1;
////}|]
verify.outliningSpansInCurrentFile(test.ranges());