TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

fix(51225): Go-to-definition on case or default should jump to the containing switch statement if available.

Open sviat9440 opened this issue 2 years ago • 4 comments

Fixes #51225

sviat9440 avatar Oct 20 '22 07:10 sviat9440

@microsoft-github-policy-service agree

sviat9440 avatar Oct 20 '22 07:10 sviat9440

Can you add one more test?

switch (null) {
    case null:
        export /*start*/default 123;
}

Validate that it doesn't jump to the switch statement.

DanielRosenwasser avatar Oct 20 '22 19:10 DanielRosenwasser

/////*c*/export default { [|/*a*/case|] };
////[|/*b*/default|];

Is it normal that b and goes to c? This is how it works now and looks like a bug. It is expected that there will be no go to anywhere.

sviat9440 avatar Oct 20 '22 19:10 sviat9440

It's questionable, but I wouldn't get hung up on fixing that specific case.

DanielRosenwasser avatar Oct 20 '22 19:10 DanielRosenwasser

@sheetalkamat I changed contextSpan to keyword + expression, but i can't find any examples for testing contextSpan with fourslash

sviat9440 avatar Nov 24 '22 05:11 sviat9440

Good to go @sheetalkamat?

DanielRosenwasser avatar Dec 09 '22 18:12 DanielRosenwasser

Any progress? @sheetalkamat

sviat9440 avatar Jan 30 '23 08:01 sviat9440

@typescript-bot pack this

sheetalkamat avatar Jan 30 '23 22:01 sheetalkamat

I am working on framework to test contextSpan with goto def which we should merge and then rebase this PR so its clearer on what is the context that is being set for contextSpan. Will link PR here once i have it ready

sheetalkamat avatar Jan 30 '23 22:01 sheetalkamat

@sviat9440 #52576 is up and once that is merged you should be able to update your PR with the baselines that verify context, Having said that, i completely mis-read context Span to be first line of declaration. It is infact the complete declaration. With that in mind i think your earlier change of having contextSpan as complete switch statement was correct and you would want to go back to that behavior. Sorry for misdirecting you on that one.

sheetalkamat avatar Feb 02 '23 19:02 sheetalkamat

#52576 is merged. Feel free to merge changes from main and baseline

sheetalkamat avatar Mar 23 '23 20:03 sheetalkamat