Reference issue: RFC#687
Predictive IntelliSense is an addition to the interactive experience to assist in command discovery
and accelerate full command execution. This enables new and experienced users of PowerShell to
discover, edit, and execute full commands based on matching predictions from the users history or
additional provider.
Tab Completion has accelerated the success of both new and experienced PowerShell users. New users get the benefit of discovery; seeing available cmdlets and parameters as options while interactively typing. Experienced users receive the benefit of acceleration; typing less while using the
The increasing amount of technology translates to an increase in cmdlets and full command
complexity. Predictive IntelliSense is an addition to the concept of Tab Completion; helping the
user discover, build and edit full commands based on the users history or additional plugins.
The proposal is to add Predictive IntelliSense and enhancements for MenuComplete/Dynamic Help to the users interactive experience.
Predictive IntelliSense Protoype maybe found on PSGallery.
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete
Set-PSReadLineKeyHandler -Key "Ctrl+f" -Function ForwardWord
Set-PSReadLineKeyHandler -Key "Ctrl+b" -Function BackwardWord
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Open discussion items:
Set-PSReadLineOption -Colors @{ Prediction = '#8A0303'}
Set-PSReadLineOption -Colors @{ Prediction = '#2F7004'}
Multiple color code values are supported currently in PSReadLine.
Examples of different color code values:
Set-PSReadLineOption -Colors @{ Prediction = 'DarkRed'}
# Use a ConsoleColor enum
Set-PSReadLineOption -Colors @{ Prediction = [ConsoleColor]::DarkRed}
# 24 bit color escape sequence
Set-PSReadLineOption -Colors @{ Prediction = "$([char]0x1b)[38;5;100m"}
# RGB value
Set-PSReadLineOption -Colors @{ Prediction = "#8181f7"}
It may be possible to support 1st party and 3rd party predictive plugins.
I'd also love to see proposed PowerShell API additions so that this isn't a shell-only feature. Something like this would be really nice in editors as well, for example.
For cmdlets/functions it should show the synopsis. Syntax sounds helpful, but on bigger commands with lots of parameters and parameter sets it's... unwieldy.
For parameters it should should show the helpmessage, that normally only surfaces at the mandatory prompt when you type !?
I want to have this available in VS Code.
As a module author, I want to be able to inject common use cases for my modules' functions.
Predictions should also be based on the current working directory. Example: In some local repos I might do a git pull origin master
but in others I do a git pull origin develop
This is amazing. Subscribed. I posted in the slack channel for vscode asking what magical vodoo was happening, as I had never seen this and it felt like such a natural thing to have. Didn't realize it got rolled out with the insiders powershell extension. Looking forward to the improvements. #win
it's work on non VT ?
One other thing about the Dynamic Help feature... the PowerShell extension has been providing this experience for a while (see the box on the right):
It's called the completionItem/resolve
request as a part of the language server protocol.
The idea here is... for a completion, give me _more details_ about it... but only send the request for more details when it is highlighted.
However, the PowerShell extension goes a step further to provide syntax as you're typing parameters too:
VS Code decided it was a good idea to separate this into it's own request called the Signature Help Request.
There are a lot of learning from the PowerShell extension and LSP that can be leveraged in the design of the features outlined here. Please consider them in the design.
This is pretty cool. The first thing I do in my $profile is
set-psreadlineoption -editmode emacs
so that pressing tab lists all the choices at once.
I just upgraded to the prerelease version of PSReadLine and I see real potential for this feature. As it is now, though, I find the history-biased suggestions a bit frustrating. Consider this scenario:
c:\foo\bar\baz
cd ..\qux
c:\foo\bar
_has no subdirectory_ named qux
c:\foo\bar\baz
, as soon as I type cd ..
a ghostly \qux
is suggested to me — a completely invalid pathOverall this seems far less useful than it would be if it were suggesting valid completions of the partially-typed command line. I'm fairly new to PSReadLine, so I'm sorry if this is a naive question, but is it possible to configure this behavior? Or to validate potential completions before suggesting them (and then not suggest invalid completions at all)?
I just upgraded to the prerelease version of PSReadLine and I see real potential for this feature. As it is now, though, I find the history-biased suggestions a bit frustrating. Consider this scenario:
- current working directory is
c:\foo\bar\baz
- at some point in the past, I have entered the command
cd ..\qux
- unfortunately,
c:\foo\bar
_has no subdirectory_ namedqux
- nevertheless, while sitting at
c:\foo\bar\baz
, as soon as I typecd ..
a ghostly\qux
is suggested to me — a completely invalid pathOverall this seems far less useful than it would be if it were suggesting valid completions of the partially-typed command line. I'm fairly new to PSReadLine, so I'm sorry if this is a naive question, but is it possible to configure this behavior? Or to validate potential completions before suggesting them (and then not suggest invalid completions at all)?
AFAIK this happens because, currently, the only prediction source available is the commands history. Since it's a WIP, there's room for improvement, and probably the first would be to get history entries and then only let through (to the user) the ones that really would apply to his current terminal state (directory, Git repo, etc).
Most helpful comment
One other thing about the Dynamic Help feature... the PowerShell extension has been providing this experience for a while (see the box on the right):
It's called the
completionItem/resolve
request as a part of the language server protocol.The idea here is... for a completion, give me _more details_ about it... but only send the request for more details when it is highlighted.
However, the PowerShell extension goes a step further to provide syntax as you're typing parameters too:
VS Code decided it was a good idea to separate this into it's own request called the Signature Help Request.
There are a lot of learning from the PowerShell extension and LSP that can be leveraged in the design of the features outlined here. Please consider them in the design.