Enable PSReadline support in the integrated console (syntax highlighting, keyboard navigation)
PSReadline is not supported in the integrated console at this time. A non-trivial amount of work is needed to make PowerShell Editor Services and PSReadline play nicely together so this could take some time.
Features this will enable:
- Ctrl+Arrow keys, etc (keyboard navigation of the input line)
- Syntax highlighting of input text
- Multi-line text input (writing a function definition in the console across multiple lines)
Getting closer! https://github.com/PowerShell/PowerShellEditorServices/pull/672
It looks like that PR has been merged into 2.0.0 - What is left to get it working with this extension in insiders? Is there anything that could use love to get this closer to reality?
@BatmanAMA @rjmholt is working on migrating PowerShell Editor Services to .NET Standard 2.0 and PowerShell Standard.
https://github.com/PowerShell/PowerShellEditorServices/pull/741
Here's a build from that latest PR (which is pretty much complete) with the PSReadLine features enabled: psvsix.zip
(GitHub won't let me upload a VSIX directly, but just expand the zip and it will be in there)
To install:
code --install-extension ./PowerShell-v2-insiders.vsix
Or if you use VSCode Insiders:
code-insiders --install-extension ./PowerShell-v2-insiders.vsix
Then you will need to enable the feature in your VSCode user settings by adding to the feature flags:
{
"powershell.developer.featureFlags": [
"PSReadLine"
]
}
There are still come trickier bugs, mainly on *nix.
If you're interested in the source, the backend can be built from this branch (I made a new one where the PSRL import is hardcoded, since the newest PowerShell Core overrides our PSRL with one that has the same version but is older -- we're waiting on the next PSRL release to fix that). The frontend is based on this branch (which is just the normal frontend with the versions changed to make installation nicer), but needs these lines removed.
Anyway, give it a try and let us know how it goes.
Right after having the new version installed, debugging was no longer possible:
Cannot debug or run a PowerShell script until the PowerShell session has started. Wait for the PowerShell session to finish starting and try again.
After some time, I get this error:
The language service could not be started:
The log shows:
9/6/2018 1:29:01 PM [NORMAL] - Visual Studio Code v1.26.1 64-bit
9/6/2018 1:29:01 PM [NORMAL] - PowerShell Extension v2.0.0
9/6/2018 1:29:01 PM [NORMAL] - Operating System: Windows 64-bit
9/6/2018 1:29:01 PM [NORMAL] - Path specified by 'powerShellExePath' setting - '' - not found, reverting to default PowerShell path.
9/6/2018 1:29:01 PM [NORMAL] - Language server starting --
9/6/2018 1:29:01 PM [NORMAL] - exe: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
9/6/2018 1:29:01 PM [NORMAL] - args: C:\Users\randr\.vscode\extensions\ms-vscode.powershell-2.0.0\modules\PowerShellEditorServices\Start-EditorServices.ps1 -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2.0.0'-AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\randr\.vscode\extensions\ms-vscode.powershell-2.0.0\modules'-EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\randr\.vscode\extensions\ms-vscode.powershell-2.0.0\logs\1536233341-15e829a8-2222-4bfd-8dd7-003ff46574671536233335047\EditorServices.log' -SessionDetailsPath 'C:\Users\randr\.vscode\extensions\ms-vscode.powershell-2.0.0\sessions\PSES-VSCode-19296-915042' -FeatureFlags @('PSReadLine')
9/6/2018 1:29:01 PM [NORMAL] - Syntax Folding Provider registered
9/6/2018 1:29:02 PM [NORMAL] - powershell.exe started, pid: 5920
9/6/2018 1:31:01 PM [NORMAL] - Language server startup failed.
9/6/2018 1:31:01 PM [ERROR] - The language service could not be started:
9/6/2018 1:31:01 PM [ERROR] - Timed out waiting for session file to appear.
@raandree This is a shot in the dark, but what's the highest .NET Framework version you have installed? If it's under 4.7.1, try installing that.
@raandree I have the same issue and I have found that the Microsoft.PowerShell.EditorServices.dll library is not in the expected path when the 'Start-EditorServices.ps1' script runs.
from the PowerShellEditorServices.psm1 ::
if (!$PSVersionTable.PSEdition -or $PSVersionTable.PSEdition -eq "Desktop") { Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.dll" Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.Host.dll" } else { Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.dll" Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.Protocol.dll" Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.Host.dll" }
On my system, I don't have Powershell 6 installed, only the Desktop version (5.1) and in the .\ms-vscode.powershell-2.0.0\modules\PowerShellEditorServices\bin folder, there is only a 'Core' folder, no 'Desktop' folder.
It seems to me that this would only work with Powershell Core installed.
@rjmholt has been working on porting all of PowerShell Editor Services to .NET Standard and this seems to be a place he missed.
Windows PowerShell 5.1 will be supported.
@SeeminglyScience, thanks for the hint, but .net 4.7.2 is installed.
PS C:\> Get-DotNetFrameworkVersion
ComputerName Build Version Comment
------------ ----- ------- -------
RAANDREE1 50727 2.0.50727.4927
RAANDREE1 30729 3.0.30729.4926
RAANDREE1 30729 3.5.30729.4926
RAANDREE1 461808 4.7.2 (Windows 10 1803)
@djobin, this is it. Missing the Desktop folder as well.
When do we get a new build to play with?
@raandree Just finishing one up now (sorry, currently in an Australian timezone, so a bit out of kilter with US business hours)
FYI, I've hit a snag but working to fix it ASAP. See https://github.com/PowerShell/PowerShellEditorServices/pull/741.
Ok I've uploaded a new VSIX in the comment above (psvsix.zip).
I've made sure that this one works with Windows PowerShell, PowerShell Core 6.0 and PowerShell Core 6.1.
Give that a try 😄
Working on Mac with 6.1 for me for the most part! At least PSReadline is working well 😃 SO AWESOME
@rjmholt Fantastic thank you for this!
Btw, I should be able to link to an AppVeyor artefact soon. It's just complicated because the two repos need to be synced.
Looking forward to seeing this in the Insiders release 👍
Working for me too on MacOS with PSCore 6.1 :).
Installed it on WinServer 2012R2 with WMF 5.1 and it does not seem work in the latest version of code or insiders (i.e. I cannot use the up/down keys to get to the last command in the debugger) unless I am doing something wrong
Have you added this to your config?
"powershell.developer.featureFlags": [
"PSReadLine"
]
@raandree Yes, thanks. I forget this as I was on a new machine, sorry, it works now :-)