-
Notifications
You must be signed in to change notification settings - Fork 13k
Prioritize case
and default
keywords in switch statement completions
#62126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
d1d0418
963e167
1695532
7f7a30e
c8b6d8c
75fcd1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @noLib: true | ||
|
||
//// declare const thing: string; | ||
|
||
//// // Basic switch block - should prioritize case/default | ||
//// switch (thing) { | ||
//// /*basic*/ | ||
//// } | ||
|
||
//// // Same - show all completions (not at switch body level) | ||
//// switch (thing) { | ||
//// case 42: | ||
//// /*sameAll1*/ | ||
//// } | ||
|
||
//// // Same - show all completions (after break at same column as case) | ||
//// switch (thing) { | ||
//// case 42: | ||
//// break; | ||
//// /*sameAll2*/ | ||
//// } | ||
|
||
//// // Same - show all completions (complex nested structure) | ||
//// switch (thing) { | ||
//// case 42: | ||
//// if (Math.random()) { | ||
//// } | ||
//// else { | ||
//// } | ||
//// /*sameAll3*/ | ||
//// } | ||
|
||
//// // After break statement with proper indentation | ||
//// switch (thing) { | ||
//// case 42: | ||
//// break; | ||
//// /*newPrio1*/ | ||
//// } | ||
|
||
//// // After same-line break statement | ||
//// switch (thing) { | ||
//// case 42: break; | ||
//// /*newPrio2*/ | ||
//// } | ||
|
||
//// // After return statement with proper indentation | ||
//// switch (thing) { | ||
//// case 42: | ||
//// return 1; | ||
//// /*newPrio3*/ | ||
//// } | ||
|
||
//// // After throw statement with proper indentation | ||
//// switch (thing) { | ||
//// case 42: | ||
//// throw new Error(); | ||
//// /*newPrio4*/ | ||
//// } | ||
|
||
// Scenarios where case/default should be prioritized | ||
goTo.marker("basic"); | ||
verify.completions({ | ||
includes: [ | ||
{ name: "case", sortText: "10" }, | ||
{ name: "default", sortText: "10" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be tested that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added explicit verification that |
||
] | ||
}); | ||
|
||
goTo.marker("newPrio1"); | ||
verify.completions({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Go back to baselining if the baselines aren't massive, and show some characteristics about the ordering. The key thing the tests need to witness is whether There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switched back to baseline testing with @nolib to keep baselines manageable (~548KB). The baseline now clearly shows the relative ordering of
Fixed in 75fcd1d. |
||
includes: [ | ||
{ name: "case", sortText: "10" }, | ||
{ name: "default", sortText: "10" } | ||
] | ||
}); | ||
|
||
goTo.marker("newPrio2"); | ||
verify.completions({ | ||
includes: [ | ||
{ name: "case", sortText: "10" }, | ||
{ name: "default", sortText: "10" } | ||
] | ||
}); | ||
|
||
goTo.marker("newPrio3"); | ||
verify.completions({ | ||
includes: [ | ||
{ name: "case", sortText: "10" }, | ||
{ name: "default", sortText: "10" } | ||
] | ||
}); | ||
|
||
goTo.marker("newPrio4"); | ||
verify.completions({ | ||
includes: [ | ||
{ name: "case", sortText: "10" }, | ||
{ name: "default", sortText: "10" } | ||
] | ||
}); | ||
|
||
// Scenarios where case/default should NOT be prioritized | ||
goTo.marker("sameAll1"); | ||
verify.completions({ | ||
includes: [ | ||
{ name: "case", sortText: "15" }, | ||
{ name: "default", sortText: "15" } | ||
] | ||
}); | ||
|
||
goTo.marker("sameAll2"); | ||
verify.completions({ | ||
includes: [ | ||
{ name: "case", sortText: "15" }, | ||
{ name: "default", sortText: "15" } | ||
] | ||
}); | ||
|
||
goTo.marker("sameAll3"); | ||
verify.completions({ | ||
includes: [ | ||
{ name: "case", sortText: "15" }, | ||
{ name: "default", sortText: "15" } | ||
] | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff is huge, so maybe this needs to run with
noLib
or some similar thing to trim down the full completion list.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@noLib: true
and switched from baseline testing to targetedverify.completions()
assertions. This reduced the test from 256k+ lines to a focused test that validates the specific sortText values ("10" for prioritized, "15" for normal) without the massive global completion list. Fixed in c8b6d8c.