Feature Request: Expose parameters to the Outline View #5153
Labels
Area-UI
Feature: VS Code
Request to use or implement a VS Code feature.
Issue-Enhancement
A feature request (enhancement).
Up for Grabs
Will shepherd PRs.
Verified
This issue has been determined to be a legitimate issue that requires a fix.
Prerequisites
Summary
Issue & Reproduction
First, searching through the open issues, this could be related to #3913, but I don't believe so as it doesn't matter whether the parameter declaration has attributes or not.
When creating a script using a
param()
block, the parameters are not included in the outline. It doesn't matter whether the parameter(s) have attributes or defined types, it doesn't appearFor example, none of the following situations result in the appearance of parameters in outline:
In all of the above cases, both
$MyString
and$MyLooselyTypedParam
are not surfaced in the Outline View in VSCode.However, I did notice that when using a function declaration, you can get the parameters to show up in the function's definition by using the in-line parameter declaration:
Where it will show up as
function My-NewFunc ([string]$MyString)
even if the parameters are split into multiple lines. In any case, using an in-line function declaration isn't exactly a solution to the problem, as it is a long string in a small sidebar.Expected Behavior
I would expect the Outline View to behave similarly as it does in other .NET languages like C#.
For instance, using the above example, the outline would look more like:
Ideally, the parameters would be a child of a separate parent named something like
param()
andbegin{}
process{}
end{}
blocks would also be represented:representing:
But just having proper support for parameters in the outline would be extremely beneficial.
Conclusion
Unfortunately, without displaying parameters, the functionality of the Outline View is very limiting and only particularly useful for either a.) small scripts or b.) poorly made scripts that don't leverage the features of PowerShell that make it better than shell scripts (or actively work around intended usage, e.g., by applying parameters to variables according to argument position like a bash/shell script).
PowerShell Version
Visual Studio Code Version
Extension Version
Steps to Reproduce
See primary description outlining the issue; reproduction only requires the use of basic PowerShell features such as
function
andparam()
.Visuals
N/A
Logs
N/A
The text was updated successfully, but these errors were encountered: