PowerShell / PowerShell/vscode-powershell

Adding Predictive IntelliSense to PowerShell VSCode Extension

未关闭
#3,301 8 条评论 5 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Area-IntelliSense Issue-Enhancement
主要语言
TypeScript
星标
1.9k
派生
548
PR 合并指标
30 天内没有已合并 PR

描述

Adding Predictive IntelliSense to PowerShell VSCode Extension

Summary of new feature

Predictive IntelliSense is an addition to the concept of tab completion that assists the user in
successfully completing commands. This enables new and experienced users of PowerShell to discover,
edit, and execute full commands based on matching predictions from the users history and additional
domain specific plugins such as
Az.Tools.Predictor.

PowerShell users would benefit from predictions in VSCode Terminal (PowerShell Integrated Console)
and Editor:

  • PowerShell users with previous cmdlet experience receive suggestions from history and additional
    plugins, accelerating the time to command completion. Historical predictions come from the users
    PSReadLine history of completed commands, allowing them to quickly accept the prediction.

  • PowerShell users without previous cmdlet experience receive guided suggestions from plugin
    predictors like Az.Tools.Predictor to help successfully complete the command. These plugins may
    provide a range of guided assistance in the form of complete commands or suggesting parameters and
    arguments.

Terminal

Terminal (PowerShell Integrated Console), should have the same features as PowerShell (shell) with
predictions as described in this
blog.

This includes InLineView and ListView for predictions, switchable with F2 key.

  • Example of InLineView in PowerShell Integrated Console:

Picture1

  • Example of ListView in PowerShell Integrated Console:

PowerShelt Integrated Console v2021 2 2

Editor

Displaying predictions in the editor could be similar to IntelliCode for Visual Studio described
here.

When the user begins to type a cmdlet, a prediction using InLineView appears above other cmdlet
names. A star indicates that the suggestion comes from a predictor, followed by the InLineView
prediction, followed by the prediction source.

Editor1

After the cmdlet name, when the user types dash (-) to begin a parameter, the first suggestion pair
(parameter and argument) is displayed along with the prediction source. As the user continues to
type the next parameter with a dash, the next suggestion pair is displayed until the prediction is
complete.

Editor2

In the above example, the Az.Tools.Predictor will suggest the parameter and argument based on:

  • Examples - Ml-based plugins may learn the most common uses of a cmdlet from documentation examples.
  • Reuse - If the parameter and argument pair has been previously typed within the current session,
    the predictor will supply the previously typed argument.
  • Syntax - If no examples or history is available, the predictor will display the parameter with the
    Object type for the argument.

Enabling/Disabling

Predictions are enabled and disabled using the Set-PSReadLineOption -PredictionSource <argument>
and may be stored in the users profile. Accepted values for the argument are None, History,
HistoryAndPlugin.

Configuring a predictor

Customizing prediction color, keybindings, and additional plugins is accomplished through PSReadLine
Set-PSReadLineOption and Set-PSReadLineKeyHandler cmdlets. Custom settings may be stored in the
users profile.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

未指定源文件、测试或入口点。首先分解 Terminal 和 Editor 的要求,然后检查扩展如何与 PSReadLine 的预测设置和预测插件集成;当受支持的历史记录/插件预测、视图、配置和键绑定都按描述工作时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
powershell, typescript, vscode
领域
developer-experience, devtools
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。