mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-12 11:08:26 -05:00
Fixed outlining spans for chained method calls. (#35860)
This commit is contained in:
committed by
Daniel Rosenwasser
parent
4942fd2b84
commit
82b0547281
@@ -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);
|
||||
|
||||
116
tests/cases/fourslash/getOutliningSpansDepthChainedCalls.ts
Normal file
116
tests/cases/fourslash/getOutliningSpansDepthChainedCalls.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
// 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());
|
||||
Reference in New Issue
Block a user