Description
Summary of the new feature
Should be able to right click (or keyboard shortcut) over a long commandlet call in the editor, and extract the parameters into a splat. This is already implemented in an outside tool, and is one of the most important tools we use in our 100,000 line of PowerShell code codebase. I'm sure you're already familiar with it, implemented by SeeminglyScience over in https://github.com/SeeminglyScience/EditorServicesCommandSuite
To argue my case: one of the main things in PowerShell that is both a blessing and a curse is its verbosity. It is incredibly clear what you are trying to do in any given script both because of its high-level-brevity (one line does what most languages need 10 for), and because of named parameters. However, the named parameters leads to very long lines of code sometimes. This is why splatting is such a necessity. However, when writing a splat from scratch, you don't get ANY autocomplete (as you are simply adding keys to a hashtable), so the only time people would START with a splat is when they are already very familiar with the parameters of the command they are about to call. However when unfamiliar or not 100% confident, you would use autocomplete every time and end up with a long line of parameters. The time comes to commit the code, and you want to clean it up for readability.
Part of every developers workflow at this point OUGHT to be converting these long lines to splats for readability (and later extensability, as well), as there is no performance downside (at least in ps 5.1, cannot speak confidently for newer versions). In practice, this is a lot of work and often people just don't do it. It isn't particularly easy to do quickly by hand in the editor, even if you lifehack it by Ctrl+D'ing on -'s, newlining, and then wrapping with a hashtable.
SeeminglySciences splat tool combined with adding a Ctrl+Shift+C to map to additional powershell commands
{ "key": "ctrl+shift+c", "command": "PowerShell.ShowAdditionalCommands", "when": "editorLangId == 'powershell'" },
saves the day here on this critical missing feature.
Unfortunately, it breaks all the time due to changes to the VSCode extension. It is hard / confusing to set up (have to edit your VSCode PowerShell profile to auto-import the EditorSuite on load).
I'm baffled that such a critical component to powershell isn't already implemented in the base PowerShell extension. Either auto-complete of parameters in a splat hashtable or extraction of splat from a commandlet call are in my eyes a necessity for the powershell community.
Proposed technical implementation details (optional)
This feature in particular should be integrated into the extension and be accessible via a single keyboard shortcut, if possible.
Perhaps ideally it should leave your cursor multi-selecting both the splat variable name and the splat usage (minus the $/@), such that you can rename it from the default quickly just by typing the new name.
Metadata
Metadata
Assignees
Type
Projects
Status