-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Add completion for switch cases for $PSBoundParameters.Keys #25349
Copy link
Copy link
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Interactive-IntelliSensetab completiontab completionWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Interactive-IntelliSensetab completiontab completionWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary of the new feature / enhancement
I occasionally write functions where I use a switch based on the bound parameters like this:
To ensure I don't make typos I tend to copy+paste the parameters but tab completing them would be much more convenient.
But before I try to add this feature, I want to be sure it would actually get accepted. Do other people use this pattern? Is this a pattern we want to encourage? If not, how do other people check if various parameters have been specified?
Proposed technical implementation details (optional)
The identifier/string completion code would be updated to check if it's completing a switch case, and if so, if the switch is on a variable with a property called
Keys.If the variable is
$PSBoundParametersit would look for the nearest param block and get results from there.If the variable is anything else we could try to look for a hashtable definition to that variable and get results from that, but I don't know if it's worth adding this because I don't think this is a particularly common pattern.
Also we could do some type inference on the variable, and if it's an Enum get the completion values from there.