TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Go-to-definition on `case` or `default` should jump to the containing `switch` statement if available.

Open DanielRosenwasser opened this issue 2 years ago • 1 comments

/*END*/switch (null) {
  /*START*/case null: break;
}
/*END*/switch (null) {
  /*START*/default: break;
}

Those should work.

The following should not have issues.

export /*a*/default {}
export default { /*a*/case }
/*b*/default;
/*c*/case 42;

DanielRosenwasser avatar Oct 19 '22 00:10 DanielRosenwasser

If you try to go to the beginning of the SwitchStatement, there is a small problem: The position after the previous expression (including spaces, line breaks, and so on) is considered to be the beginning of the SwitchStatement

TestCase:

////      switch (null) {
////          case null: break;
////      }
////
////      /*end*/switch (null) {
////         [|/*start*/case|] null: break;
////      }

Result:

// @Filename: /tests/cases/fourslash/goToDefinitionSwitch4.ts
     switch (null) {
         case null: break;
     }/*ACTUAL*/

     /*EXPECTED*/switch (null) {
        case null: break;
     }

I suggest going to the beginning of the block and not to the beginning of the SwitchStatement

////      switch (null) {
////          case null: break;
////      }
////
////      switch (null) /*end*/{
////         [|/*start*/case|] null: break;
////      }

Or:

////      switch (null) {
////          case null: break;
////      }
////
////      switch (/*end*/null) {
////         [|/*start*/case|] null: break;
////      }

sviat9440 avatar Oct 20 '22 06:10 sviat9440

close this issue if it fixed @DanielRosenwasser

MohitBansal321 avatar Feb 22 '23 06:02 MohitBansal321

is the issue fixed?

Rohankeshav avatar Oct 01 '23 22:10 Rohankeshav