`Find-Ast -AtCursor` doesn't work inside `param(...)` blocks.
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- powershell, vscode
调研方向
使用 PowerShell Integrated Console 中的 Find-Ast -AtCursor 重现该问题,并将光标置于 param(...) 块中的 $Foo 内。跟踪命令对光标位置的处理,并验证结果是 System.Management.Automation.Language.ParameterAst,而不是 NamedBlockAst。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- C#
- 星标
- 780
- 派生
- 267
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PowerShell/PowerShellEditorServices 的其他 Issue
-
Issue-Enhancement Needs: Triage
难度 3/5 1-2 天 新手友好度 35/100
-
[Bug] None of the string overloads of `EditorExtensionServiceProvider.GetService()` work on .NET.可能重新可做 @andyleejordan 于 143 天前认领,目前没有进行中的 PR。 未关闭
PowerShell/PowerShellEditorServices#2331 · 1 个 reaction · 已指派 2 人 ·
-
Area-Language Server Issue-Enhancement
难度 4/5 3-5 天 新手友好度 48/100
PowerShell/PowerShellEditorServices#2315 · 1 条评论 ·
-
Improve Constrained Runspace Debug Experience可能已有人在做 @JustinGrote 于 166 天前认领。 未关闭Area-Debugging Issue-Enhancement
PowerShell/PowerShellEditorServices#2294 · 1 个 reaction · 已指派 2 人 ·
-
Issue-Bug Needs: Triage
难度 4/5 3-5 天 新手友好度 48/100
PowerShell/PowerShellEditorServices#2293 · 1 条评论 ·
查看 PowerShell/PowerShellEditorServices 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
vikramlearning/blazorbootstrap#1388 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
GamaEdtech/gamatrain-back#977 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
valkey-io/valkey-glide#7745 ·
维护者通常 1 天内回复
-
area-templates triage:bot-seen triage:needs-human
难度 2/5 1-3 小时 新手友好度 75/100
microsoft/aspire#22356 · 1 条评论 ·
维护者通常 1 天内回复
-
Needs-Triage
难度 2/5 1-3 小时 新手友好度 84/100
PowerShell/PowerShell#28432 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复