You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Expose parameters to the Outline View #5153
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 appear
For example, none of the following situations result in the appearance of parameters in outline:
# As a Cmdlet:
[CmdletBinding()]
param(
[Parameter()]
[string]
$MyString,
[Parameter()]
$MyLooselyTypedParam
)
# As a scriptparam(
[string]$MyString,$MyLooselyTypedParam
)
# As an in-script Cmdlet:functionNew-MyFunc {
[CmdletBinding()]
param(
[Parameter()]
[string]
$MyString,
[Parameter()]
$MyLooselyTypedParam
)
}
# As an in-script function:functionNew-MyFunc {
param(
[string]$MyString,$MyLooselyTypedParam
}
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:
functionNew-MyFunc([string]$MyString) {
# ...
}
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:
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).
It is certainly possible to expose these via the Outline, we would probably make it an opt-in parameter. Marking this as Up For Grabs and changing it to enhancement.
This will probably first require semantic highlighting enabled and working, as the existing textmate grammer does not explicitly detect parameters, but rather just identifies them as variables.
As an alternative, ctrl+T (Go to symbol in workspace) lets you quickly find and navigate to any symbol in the environment, and parameters are present there.
Justin Grote (@JustinGrote) The Outline view is lit up by the DocumentSymbolHandler, and we are literally just skipping parameters (and I'm not sure why, the comment just says it should only include declarations):
Andy Jordan (@andyleejordan) right, I just figured we should be consistent if we light it up in the documentsymbolhandler, the symbol as presented to the user should be consistent.
We can probably make this an opt-in (or opt-out) option so as not to jar people's view who are used to not seeing parameters.
Activity
JustinGrote commentedon Mar 7, 2025
Thank you for your submission!
It is certainly possible to expose these via the Outline, we would probably make it an opt-in parameter. Marking this as
Up For Grabsand changing it to enhancement.This will probably first require semantic highlighting enabled and working, as the existing textmate grammer does not explicitly detect parameters, but rather just identifies them as variables.
As an alternative, ctrl+T (Go to symbol in workspace) lets you quickly find and navigate to any symbol in the environment, and parameters are present there.
[-]Parameters do not appear in the Outline View[/-][+]Feature Request: Expose parameters to the Outline View[/+]andyleejordan commentedon Mar 12, 2025
Justin Grote (@JustinGrote) The Outline view is lit up by the
DocumentSymbolHandler, and we are literally just skipping parameters (and I'm not sure why, the comment just says it should only include declarations):if (!symbolReference.IsDeclaration || symbolReference.Type is SymbolType.Parameter)
JustinGrote commentedon Mar 12, 2025
Andy Jordan (@andyleejordan) right, I just figured we should be consistent if we light it up in the documentsymbolhandler, the symbol as presented to the user should be consistent.
We can probably make this an opt-in (or opt-out) option so as not to jar people's view who are used to not seeing parameters.