diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index ce0fe7b28be..7b97161aabe 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -45,7 +45,14 @@ namespace ts.OutliningElementsCollector { if (span) out.push(span); depthRemaining--; - if (isIfStatement(n) && n.elseStatement && isIfStatement(n.elseStatement)) { + if (isCallExpression(n)) { + depthRemaining++; + visitNonImportNode(n.expression); + depthRemaining--; + n.arguments.forEach(visitNonImportNode); + n.typeArguments?.forEach(visitNonImportNode); + } + else if (isIfStatement(n) && n.elseStatement && isIfStatement(n.elseStatement)) { // Consider an 'else if' to be on the same depth as the 'if'. visitNonImportNode(n.expression); visitNonImportNode(n.thenStatement); diff --git a/tests/cases/fourslash/getOutliningSpansDepthChainedCalls.ts b/tests/cases/fourslash/getOutliningSpansDepthChainedCalls.ts new file mode 100644 index 00000000000..9fc8c50dd70 --- /dev/null +++ b/tests/cases/fourslash/getOutliningSpansDepthChainedCalls.ts @@ -0,0 +1,116 @@ +/// + +// Tests that each 'else if' does not count towards a higher nesting depth. + +////declare var router: any; +////router +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) +//// .get("/", async(ctx) =>[|{ +//// ctx.body = "base"; +//// }|]) +//// .post("/a", async(ctx) =>[|{ +//// //a +//// }|]) + +verify.outliningSpansInCurrentFile(test.ranges());