vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

Enable PSReadline support in the integrated console (syntax highlighting, keyboard navigation)

Open daviwil opened this issue 9 years ago • 133 comments

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)

daviwil avatar Mar 14 '17 14:03 daviwil

@darkquake93 if you just import the standard PSReadline module into the PS extension's Integrated Console, it will break all language and debugging functionality. @SeeminglyScience's work is to enable PSReadline to coexist with the PowerShell extension's language capabilities.

daviwil avatar Mar 04 '18 15:03 daviwil

Oh I didn't realise. I only use Powershell for minimal use on my home Windows 7 machine, and all seems good for the time being with syntax highlighting and ctrl+delete etc working. I'll keep that in mind though, but my computer at work is already on Windows 10 so that's probably where I'll do debugging in the future, I just like to run simple scripts at home :)

darkquake93 avatar Mar 04 '18 16:03 darkquake93

When o When will this be there?

rddoove avatar Mar 26 '18 15:03 rddoove

https://www.youtube.com/watch?v=39S3dLDEbYs :-)

rkeithhill avatar Mar 26 '18 15:03 rkeithhill

You're welcome to try installing the module anyway like I did, I found it was good enough.

darkquake93 avatar Mar 27 '18 09:03 darkquake93

@darkquake93 It sounds like you are talking about getting PSReadLine to work in Windows 7, this discussion is for getting PSReadLine to work within the console created by this extension in VSCode. We explicitly remove the module at start up because it breaks all editor features, just installing the module wouldn't make a difference in this case.

SeeminglyScience avatar Mar 27 '18 11:03 SeeminglyScience

Oh sorry, you're right. Thanks for the explanation anyway.

darkquake93 avatar Mar 27 '18 12:03 darkquake93

Any update on when this will be available?

codykonior avatar Mar 28 '18 01:03 codykonior

Any news about this feature?

jtuttas avatar Apr 07 '18 11:04 jtuttas

@SeeminglyScience is working really hard on this. We had a demo at the MVP Summit in March but it still has a few bugs he is figuring out. It's a substantial change to PowerShell Editor Services.

TylerLeonhardt avatar Apr 10 '18 23:04 TylerLeonhardt

:shipit:

Liquidmantis avatar Apr 11 '18 01:04 Liquidmantis

Not sure if it's the same core problem, but when hitting F8 on a line of code, focus changes to the integrated console instead of the code, which is different from powershell_ise behavior. I prefer the powershell_ise behavior, not sure how many others do. (Answered below by tylerl0706 - thx)

uttampcu avatar May 15 '18 00:05 uttampcu

@uttampcu you're going to want to set the powershell.integratedConsole.focusConsoleOnExecute setting. That will do what you want. It behaves the way it does in order to be accessible.

TylerLeonhardt avatar May 15 '18 01:05 TylerLeonhardt

Any workarounds available for Issue #535 while we wait? Can we get @SeeminglyScience 's pre-release code to reduce the pain?

uttampcu avatar May 15 '18 01:05 uttampcu

Is inability to press arrow up/down to go previous/last command issued during debugging is part of this issue?

artisticcheese avatar May 15 '18 13:05 artisticcheese

@artisticcheese that will also be fixed with PSReadLine

TylerLeonhardt avatar May 15 '18 14:05 TylerLeonhardt

Looking forward to this update also!

chrisjeter avatar May 18 '18 15:05 chrisjeter

I believe our integration with PSReadLine depends on a PSReadLine 2 API, which is incompatible with PowerShell versions below v5. So before we can bring PSReadLine in, we will need to resolve our support story for PowerShell v4 and below.

Please see here: https://github.com/PowerShell/vscode-powershell/issues/1310

rjmholt avatar May 18 '18 17:05 rjmholt

To me, this sounds like this will last a long time before we get this available. I opened an issue back in August 2017 (https://github.com/PowerShell/vscode-powershell/issues/975 ) mentionning the fact that history and up and down arrow keys don't work. I got told it would be fixed with the introduction of PSreadLine.

As matter a fact, according to https://github.com/PowerShell/vscode-powershell/issues/1310 mentionned above, you want to drop the support for powershell v3, v4. Which means that the original issue (that a lot of people seem to be asking for) won't be fixed when working on scripts on older versions of powershell.

To me, this is a crucial functionality for any IDE, which really enhance the user experience. I think everybody has waited pretty long for this fix. This drives me nuts sometimes, and I was actually really looking forward to it.

Stephanevg avatar May 25 '18 20:05 Stephanevg

@Stephanevg I understand your frustration but that issue in particular is more complicated than it probably appears. I looked into this awhile ago and the fix is actually pretty easy, but it's currently hiding a bigger issue.

Right now when you run a command through the debugger there is no way to suppress it from history. This includes all of the commands we run in the background to get variables, the call stack, intellisense, everything. A lot of those commands get invoked every single time a command is ran from the prompt and/or every time the debugger steps. So currently, if you could navigate history, you'd be looking at mostly the background commands.

Keep in mind this is a PowerShell API, so the older versions are pretty much set in stone. Usually we can find some sort of workaround to kind of fake the same functionality, but this one is pretty solidly hard coded in.

PSReadLine solves this in a way because it has it's own history management system. But getting that working with the other editor features requires changes to PSReadLine. Older versions of PSReadLine support PSv3/4 but the newest one (the one we have to add these changes to) does not.

All that said remember you can still write scripts targeting v3/4, you only need PSv5.1 installed on your dev machine. For example, if you are currently writing scripts that target PSv2 then nothing will change because we already don't support that version.

SeeminglyScience avatar May 25 '18 21:05 SeeminglyScience