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)
Just FYI everyone, we've checked and respun the builds to make sure no event-stream stuff is in them now. I would recommend changing over to the new builds.
We're working on sorting out a couple of issues in the latest 1.x release before investing the time in rebasing 2.0.0, but it will happen soon.
There is one last major issue we're working through to make PSReadLine support viable, involving prompt cancellation -- so we want to fix that before we create a proper release channel. We're working on it, but @TylerLeonhardt and I are currently juggling some other stuff at the minute (I am porting Windows PowerShell modules to work with PowerShell Core, for example). Anyway, we're very conscious of all of it, we just want to make sure that when we release it's something that will be reliable and useful.
When can we hope to get the "endless loop" problem fixed? This is a showstopper for moving from ISE to VScode…
Btw, this also blocks the fix for this issue that is fixed in PSReadLine but still appears in the integrated console: https://github.com/PowerShell/PowerShell/issues/5983
Any status update on this?
You can try this feature via the preview version of the extension. See https://blogs.msdn.microsoft.com/powershell/2019/01/23/announcing-the-powershell-preview-extension-in-vscode/
Tried it, it's still unusable due to the "endless prompting loop" issue (which you said you encountered too at https://github.com/PowerShell/vscode-powershell/issues/1570#issuecomment-457621468)!
What could I do to help fix that?
@sba923 You're the only one complaining about an "endless loop" issue for which you've been prompted for further diagnostic information. I suggest opening an issue if you actually have a problem instead of detracting from this 2.0 discussion.
I'm not the only one, see @rkeithhill's comment on the existing issue for that exact "endless loop" problem. This is related to non-US keyboard layouts, and just makes version 2.0 of the PowerShell extension for VScode plainly unusable if you happen to have such a keyboard.
Why does the Integrated Console even have to be visible? Why not start a PowerShell instance in the background for error-checking, etc.?
@doxxx - It doesn't. You can uncheck PowerShell > Integrated Console: Show On Startup in your Code settings to not show it if you prefer it not to show. This should still allow the language server to start so you get the rest of the features that come with that (i.e. error checking).
@scrthq I do have that disabled. The problem, however, is that when I press the Terminal: Focus Terminal shortcut, it shows me the PowerShell Integrated Console. IMO, it shouldn't even appear in the list of terminals if that option is disabled.
The problem with that is that the PowerShell Integrated Console holds the PowerShell session that is used to give all the editor features - intellisense, codelens, etc.
This was done to give an experience similar to that of the ISE (editor up top, console on the bottom) - something that a lot of users had to have to adopt the PowerShell extension.
Short of major architectural change, what you're asking for is not going to be possible, I'm afraid.
Maybe someone could take PowerShell Editor Services which is the backend to the PowerShell extension and leverage the -Stdio flag to create a "PowerShell lite" extension that does more what you're looking for... but it's probably not something we can address in the short term at least.
I hadn't realized that replicating the experience of the PowerShell ISE was the goal of the extension. That explains a lot. :)
I just tried the PowerShell Preview extension with the PSReadLine support enabled. Everything appears to be working correctly! Thanks so much for this!
Is Ctrl+Backspace supposed to be working with PSReadLine support in the latest preview build?
Try putting this in your VSCode specific profile - (Microsoft.VSCode_profile.ps1):
Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord
Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord
Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete
Try putting this in your VSCode specific profile - (Microsoft.VSCode_profile.ps1):
Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete
Thanks - I had to put this in Microsoft.PowerShell_profile.ps1, but it worked!
$profile is set to that file according to VSCode's terminal.
Sorry, I thought you were trying out the PSRL support in the PowerShell Integrated Console which does load the VSCode profile. The profile you put this in will load in both the PSIC and the regular integrated terminal. But it will also load this into any PowerShell console. You might want to fire up a PowerShell console and make sure backspace still works as you expect.
I have ConPTY set up with the VSCode extension, if that makes any difference. I changed that after seeing somewhere (github issue, probably) that I should use ConPTY to have keyboard shortcuts like this.
Cool. Well if you wind up with issues in the external PowerShell console, you could conditionally invoke the above script like so:
if ($env:TERM_PROGRAM -eq "vscode") {
Set-PSReadLineKeyHandler -Chord 'Ctrl+w' -Function BackwardKillWord
Set-PSReadLineKeyHandler -Chord 'Alt+D' -Function KillWord
Set-PSReadLineKeyHandler -Chord 'Ctrl+@' -Function MenuComplete
}
There is also a $env:TERM_PROGRAM_VERSION that might come in handy.