Feature Request: Expose parameters to the Outline View
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- powershell, typescript
- Ambito
- developer-experience, tooling
Direzione di ricerca
Inizia tracciando la gestione di Outline View dell’estensione per le dichiarazioni di funzioni e param() di PowerShell, usando gli esempi di riproduzione come input previsto. Confronta il comportamento esistente dei parametri di funzione inline con i parametri basati su blocchi; il lavoro è completato quando i parametri dei blocchi param() di script e funzioni compaiono nell’outline, con la gerarchia richiesta quando supportata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- If this is a security issue, I have read the security issue reporting guidance.
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 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 script
param(
[string]$MyString,
$MyLooselyTypedParam
)
# As an in-script Cmdlet:
function New-MyFunc {
[CmdletBinding()]
param(
[Parameter()]
[string]
$MyString,
[Parameter()]
$MyLooselyTypedParam
)
}
# As an in-script function:
function New-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:
function New-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:
[f(x) icon] New-MyFunc
[(x) icon] $MyString
[(x) icon] $MyLooselyTypedParam
Ideally, the parameters would be a child of a separate parent named something like param() and begin{} process{} end{} blocks would also be represented:
[icon] param()
[(x) icon] $MyString
[(x) icon] $MyLooselyTypedParam
[f(x) icon] New-MyFunc
[icon] param()
[(x) icon] $MyNewFuncString
[(x) icon] $MyNewFuncLooselyTypedParam
[(x) icon] $myLocalFuncString
[(x) icon] $myLocalFuncInt
[icon] begin
[(x) icon] $myLocalScriptString
[(x) icon] $myLocalScriptInt
representing:
[CmdletBinding()]
param(
[Parameter()]
[string]
$MyString,
[Parameter()]
$MyLooselyTypedParam
)
function New-MyFunc {
[CmdletBinding()]
param(
[Parameter()]
[string]
$MyString,
[Parameter()]
$MyLooselyTypedParam
)
$myLocalFuncString = "From Earth"
$myLocalFuncInt = 12
}
begin {
$myLocalScriptString = "Hello World"
}
$myLocalScriptInt = 55
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
$PSVersionTable; $Host
Name Value
---- -----
PSVersion 7.5.0
PSEdition Core
GitCommitId 7.5.0
OS Arch Linux
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name : Visual Studio Code Host
Version : 2025.0.0
InstanceId : e8d9e3f0-3500-4140-8739-f7f403df2d5f
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
Visual Studio Code Version
code --version
1.98.0
6609ac3d66f4eade5cf376d1cb76f13985724bcb
x64
Extension Version
code --list-extensions --show-versions --profile 'Shell Scripting' | Select-String powershell
[email protected]
Steps to Reproduce
See primary description outlining the issue; reproduction only requires the use of basic PowerShell features such as function and param().
Visuals
N/A
Logs
N/A
- Lingua principale
- TypeScript
- Stelle
- 1.9k
- Fork
- 549
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PowerShell/vscode-powershell
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
PowerShell/vscode-powershell#5615 · 1 commento ·
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
PowerShell/vscode-powershell#5607 ·
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
PowerShell/vscode-powershell#5599 · 3 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
PowerShell/vscode-powershell#5592 · 2 commenti · 1 reazione ·
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
PowerShell/vscode-powershell#5583 · 1 commento ·
Tutte le issue di PowerShell/vscode-powershell
Issue simili
-
bot:ai-assisted status:untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
midnightntwrk/midnight-js#1424 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
mksglu/context-mode#1268 ·
I maintainer di solito rispondono entro 5 giorni
-
Edit:Apertacheck:failed streams:edit
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
iptv-org/iptv#54352 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Table] reserveSelectedRowOnPaginate=false 时表头全选包含其他页数据Forse già presa @dvd233 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Tencent/tdesign-react#4416 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
area:widget bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
interledger/publisher-tools#894 ·
I maintainer di solito rispondono entro 1 giorno