`Find-Ast -AtCursor` doesn't work inside `param(...)` blocks.
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- powershell, vscode
- Domaine
- developer-experience, tooling
Piste de recherche
Reproduisez le problème avec Find-Ast -AtCursor depuis la PowerShell Integrated Console, avec le curseur à l’intérieur de $Foo dans un bloc param(...). Suivez la gestion de l’emplacement du curseur par la commande et vérifiez que le résultat est System.Management.Automation.Language.ParameterAst plutôt que NamedBlockAst.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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 PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
- I have verified that I am using the latest version of PowerShell Editor Services.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
In Visual Studio Code with the PowerShell extension installed, placing the cursor inside a param(...) block in or next to a parameter (variable) declaration and calling Find-Ast -AtCursor doesn't recognize the cursor location as a System.Management.Automation.Language.ParameterAst instance and instead returns the entire script (System.Management.Automation.Language.NamedBlockAst)
It currently only works in inline parameter declarations of functions.
PowerShell Version
PowerShell 7.4.0
Editor Version
Visual Studio Code 1.85.1
PowerShell Editor Services Version
3.13.0
Steps to Reproduce
- Using the PIC (PowerShell Integrated Console) in Visual Studio code with
psedit $PROFILE, add the following code to$PROFILE(and ensure that profile loading is enabled):
function Rename-Variable {
param($Context)
$variable = Find-Ast -AtCursor
$variable.GetType().Fullname | Write-Verbose -Verbose
}
- Then add F2 as a keybinding, via
keybindings.json:
{
"key": "F2",
"command": "PowerShell.InvokeRegisteredEditorCommand",
"args": {
"commandName": "Rename-Variable"
},
"when": "editorLangId == 'powershell' && editorTextFocus"
}
- Start a new session, and create a PowerShell script file with the following content:
param(
[string] $Foo
)
- Place the cursor in the middle of
$Fooand press F2
You should see System.Management.Automation.Language.ParameterAst, but currently get System.Management.Automation.Language.NamedBlockAst
Visuals
Logs
No response
- Langage dominant
- C#
- Étoiles
- 767
- Forks
- 266
- Merge moyen
- 3 j 16 h
- PR mergées (30 j)
- 1
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de PowerShell/PowerShellEditorServices
-
[Bug] None of the string overloads of `EditorExtensionServiceProvider.GetService()` work on .NET. Ouverte
PowerShell/PowerShellEditorServices#2331 · 1 réaction · 2 personnes assignées ·
-
Area-Language Server Issue-Enhancement
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
PowerShell/PowerShellEditorServices#2315 · 1 commentaire ·
-
Area-Debugging Issue-Enhancement
PowerShell/PowerShellEditorServices#2294 · 1 réaction · 2 personnes assignées ·
-
Issue-Bug Needs: Triage
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
PowerShell/PowerShellEditorServices#2293 · 1 commentaire ·
-
PowerShell/PowerShellEditorServices#2282 · 1 commentaire · 1 réaction · 2 personnes assignées ·
Toutes les issues de PowerShell/PowerShellEditorServices
Issues similaires
-
bug frontend good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
NavigationViewItemAutomationPeer implements IInvokeProvider but never advertises the Invoke pattern Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
unoplatform/uno#24629 ·
-
agentic-workflows Needs: Triage :mag: State: In-PR
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
-
CS0162 "Unreachable code detected" warning from a MSBuildTemp .tmp file in every game project Ouvertebug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
-
Type: enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
apache/arrow-adbc#4809 ·