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)
@rjmholt, thanks for the new version, this is a real improvement. Two things that I am missing:
- CTRL+Backspace does not delete the word left to the cursor but results in ^W.
- Clear-Screen still does not really clear the screen
- When killing the terminal using the recycle bin icon you will be asked if you want to restart it. If I click on yes, the terminal is created in the background but not shown. I have to create another terminal (Terminal -> New Terminal), kill the 2nd one to finally see the 1st one. This does not seem to be related to 2.0 of the PowerShell extension. I have this behavior since a week or two.
- Rich copy from the terminal would be very nice.
Set the following PSRL handlers in your VSCode specific profile:
Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord
Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete
Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord
I'm assuming you're using the default Windows EditMode. If you use something else (Vi/Emacs) you may want other mappings.
Clear-Screen still does not really clear the screen
This is an issue with VSCode and not the PS extension (or the PSRL integration). See https://github.com/Microsoft/vscode/issues/30638 and https://github.com/Microsoft/vscode/issues/45693
I hate to say, but I can't get that latest test build to install...
I've uninstalled v1.9.0 of the extension, and then run:
"c:\Program Files\Microsoft VS Code\Code.exe" --install-extension d:\tmp\Powershell-v2-extremely-alpha.vsix
from a CMD prompt.
VScode starts up, but the extension isn't installed.
What am I missing?
If you try the same with a --verbose flag, that should provide more information to work with
@sba923 that exe just launches code, the CLI arguments don't work with it. Try this:
& "C:\Program Files\Microsoft VS Code\bin\code.cmd" --install-extension D:\tmp\Powershell-v2-extremely-alpha.vsix
Ah I didn't catch the .exe ending there (I remember it briefly giving me pause, but I dismissed it), nice one @SeeminglyScience!
Tada!
PS D:/tmp> & 'C:\Program Files\Microsoft VS Code\bin\Code.cmd' --install-extension .\Powershell-v2-extremely-alpha.vsix
Code.cmd : [createInstance] extensionManagementService depends on downloadService which is NOT registered.
At line:1 char:1
+ & 'C:\Program Files\Microsoft VS Code\bin\Code.cmd' --install-extensi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ([createInstance...NOT registered.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Extension 'Powershell-v2-extremely-alpha.vsix' was successfully installed!
After that, starting VScode gets me something unusable ;-(
The Terminal pane starts a PowerShell, which shows the prompt repeatedly in an endless loop, like if I was holding the Enter key down for it to autorepeat...
Ah I've seen that before at some point. I think rather than trying to debug that, hold tight for a couple of days and we should have an AppVeyor asset to point to by then
Ok, I've built a new one while doing some testing, so thought I should upload it here: psvsix.zip
All the links above also point to this one now.
This one is rebased on all the stability and performance work done in v1.9.0. As always, let me know if there are any issues.
Thank you for the great work on this. For me, it was the only thing holding the extension back.
I've been testing for the last hour and I cannot get the Killword function to work with "Ctrl+Delete". Instead, I just get a "D" character.
Set-PSReadlineKeyHandler -Chord "Ctrl+Delete" -Function KillWord
If I change it to "Ctrl+D" it works. I've also enable the flag in my config.
Thank you again, this is fantastic.
@GaryChan1 Did you try this:
Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord
See my previous comment
Perhaps someone can point me in the right direction. I am running Code Insiders
Version: 1.28.0-insider (system setup)
Commit: 85d970acdee48f6dcecf909a0faeb3c6882217a9
Date: 2018-10-02T22:27:52.997Z
Electron: 2.0.9
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64
Installed the vsix file with: code-insiders --install-extension C:\Users\xxxxx\Downloads\Powershell-v2-extremely-alpha.vsix
I also put in...
{
"powershell.developer.featureFlags": [
"PSReadLine"
]
}
And opened VSCode and it thinks for a moment and then displays the following in the terminal pane:
An error occurred while starting PowerShell Editor Services:
Could not load file or assembly 'System.Security.AccessControl, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath,
ObjectHandleOnStack retAssembly)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblies(IEnumerable`1 assemblies)
at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()
at System.Management.Automation.Cmdlet.DoEndProcessing()
at System.Management.Automation.CommandProcessorBase.Complete()
It then gives me the opportunity to see another log which displays this:
10/2/2018 8:29:37 PM [NORMAL] - Visual Studio Code v1.28.0-insider 64-bit
10/2/2018 8:29:37 PM [NORMAL] - PowerShell Extension v2.0.0
10/2/2018 8:29:37 PM [NORMAL] - Operating System: Windows 64-bit
10/2/2018 8:29:37 PM [NORMAL] - Language server starting --
10/2/2018 8:29:37 PM [NORMAL] - exe: C:\Program Files\PowerShell\6.0.2\pwsh.exe
10/2/2018 8:29:37 PM [NORMAL] - args: C:\Users\XXXXX\.vscode-insiders\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\XXXXX\.vscode-insiders\extensions\ms-vscode.powershell-2.0.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\XXXXX\.vscode-insiders\extensions\ms-vscode.powershell-2.0.0\logs\1538530177-70a76287-30ba-4526-bb28-9041ee5121c11538530173284\EditorServices.log' -SessionDetailsPath 'C:\Users\XXXXX\.vscode-insiders\extensions\ms-vscode.powershell-2.0.0\sessions\PSES-VSCode-10260-653975' -FeatureFlags @()
10/2/2018 8:29:37 PM [NORMAL] - Syntax Folding Provider registered
10/2/2018 8:29:40 PM [NORMAL] - powershell.exe started, pid: 4344
10/2/2018 8:31:35 PM [NORMAL] - Language server startup failed.
10/2/2018 8:31:35 PM [ERROR] - The language service could not be started:
10/2/2018 8:31:35 PM [ERROR] - Timed out waiting for session file to appear.
Also I did also try Run As Administrator on VSCode and got the same error.
I am sure it is something simple I didn't set up correctly ;-)
@scotthardwick What version of .NET do you have installed? If you don't have at least 4.7.1, give that an update and see if that fixes it
@rkeithhill That did it, thank you.
@scotthardwick can you also provide the output of:
$PSVersionTable
and
gci ~/.vscode-insiders/extensions/ms-vscode.powershell-2.0.0/modules/PowerShellEditorServices/bin/* -Recurse
@SeeminglyScience and @rjmholt I have fiddled around some more and updated from Powershell 6.0.2 to 6.1.0 and now it works! I guess I didn't realize there was a minimum required spec there. Thanks for answering, it got me poking around at versions!
Hmmmm, it ought to work with 6.0.x — I specifically tested that scenario (because it works differently to 6.1.x in terms of those Windows dependencies).
Can you provide the output of the above commands?
I have already installed 6.1 so not sure if this is still useful, but here it is!
With "powershell.powerShellExePath": "C:\Program Files\PowerShell\6\pwsh.exe",
$PSVersionTable
Name Value
---- -----
PSVersion 6.1.0
PSEdition Core
GitCommitId 6.1.0
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
gci ~/.vscode-insiders/extensions/ms-vscode.powershell-2.0.0/modules/PowerShellEditorServices/bin/* -Recurse
Directory: C:\Users\XXXXX\.vscode-insiders\extensions\ms-vscode.powershell-2.0.0\modules\PowerShellEditorServices\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/2/2018 8:28 PM 6.0
d----- 10/2/2018 8:28 PM Desktop
-a---- 10/2/2018 8:28 PM 9052 libdisablekeyecho.dylib
-a---- 10/2/2018 8:28 PM 8840 libdisablekeyecho.so
-a---- 10/2/2018 8:28 PM 396800 Microsoft.PowerShell.EditorServices.dll
-a---- 10/2/2018 8:28 PM 35328 Microsoft.PowerShell.EditorServices.Host.dll
-a---- 10/2/2018 8:28 PM 8572 Microsoft.PowerShell.EditorServices.Host.pdb
-a---- 10/2/2018 8:28 PM 129100 Microsoft.PowerShell.EditorServices.pdb
-a---- 10/2/2018 8:28 PM 252416 Microsoft.PowerShell.EditorServices.Protocol.dll
-a---- 10/2/2018 8:28 PM 69612 Microsoft.PowerShell.EditorServices.Protocol.pdb
-a---- 10/2/2018 8:28 PM 639488 Newtonsoft.Json.dll
-a---- 10/2/2018 8:28 PM 118272 Serilog.dll
-a---- 10/2/2018 8:28 PM 8704 Serilog.Sinks.Async.dll
-a---- 10/2/2018 8:28 PM 31744 Serilog.Sinks.Console.dll
-a---- 10/2/2018 8:28 PM 26624 Serilog.Sinks.File.dll
-a---- 10/2/2018 8:28 PM 4096 UnixConsoleEcho.dll
Directory:
C:\Users\XXXXX\.vscode-insiders\extensions\ms-vscode.powershell-2.0.0\modules\PowerShellEditorServices\bin\6.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 10/2/2018 8:28 PM 29840 System.IO.Pipes.AccessControl.dll
-a---- 10/2/2018 8:28 PM 104584 System.Security.AccessControl.dll
-a---- 10/2/2018 8:28 PM 82576 System.Security.Principal.Windows.dll
Directory:
C:\Users\XXXXX\.vscode-insiders\extensions\ms-vscode.powershell-2.0.0\modules\PowerShellEditorServices\bin\Desktop
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 10/2/2018 8:28 PM 25744 System.IO.Pipes.AccessControl.dll
-a---- 10/2/2018 8:28 PM 39048 System.Security.AccessControl.dll
-a---- 10/2/2018 8:28 PM 23688 System.Security.Principal.Windows.dll
I think my work computer still has 6.0.2 on it, so I can try that tomorrow for you if it would be useful.
Hmmmm the binaries are there... And the startup script should be adding them before it can fail to resolve...