Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
daviwil opened this issue Mar 14, 2017 · 130 comments

Comments

@daviwil
Copy link
Collaborator

@daviwil daviwil commented Mar 14, 2017

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 daviwil added this to the Backlog milestone Mar 14, 2017
@dotps1

This comment has been minimized.

Copy link

@dotps1 dotps1 commented Mar 14, 2017

i was going to request this yesterday but i got distracted.

@cobdev

This comment has been minimized.

Copy link

@cobdev cobdev commented Mar 17, 2017

Thank you!

@Liquidmantis

This comment has been minimized.

Copy link

@Liquidmantis Liquidmantis commented Jun 20, 2017

Hopefully this will include PSReadline's Vi EditMode and ViModeIndicator. I found this issue while searching for a way to get vi mode working.

@gwojan

This comment has been minimized.

Copy link

@gwojan gwojan commented Jul 4, 2017

Um, @daviwil, when did PSReadline start working in the VSCode PowerShell terminal window? I just opened the terminal and noticed my PSReadline history was available. A quick Set-PSReadlineOption -EditMode Vi and I'm in hog heaven!

Is there something I should be watching for? I guess I should mention: Windows 10 Anniversary Update, PowerShell 5.1, VSCode 1.13.1, PowerShell addin 1.4.1...

@rkeithhill

This comment has been minimized.

Copy link
Collaborator

@rkeithhill rkeithhill commented Jul 4, 2017

PSReadline support in the PowerShell terminal is a VSCode feature. What isn't implemented yet is PSReadline support in the PowerShell Integrated Console.

@daviwil

This comment has been minimized.

Copy link
Collaborator Author

@daviwil daviwil commented Jul 5, 2017

Hey Greg, unfortunately you're just seeing PSReadLine work inside of plain powershell.exe in the integrated terminal. As Keith mentions, it doesn't currently work in the PowerShell Integrated Console yet. I've started working on that last week though so I expect to have some progress soon!

@gwojan

This comment has been minimized.

Copy link

@gwojan gwojan commented Jul 5, 2017

Thanks @daviwil and @rkeithhill! I guess I need to start playing with the Integrated Console because I'm sure I knew it was there. It will be great to have PSReadline support because that one particular feature is why I abandoned the ISE a long time ago. I'm such a lousy typist I need all the help I can get. ;-)

@daviwil daviwil removed this from the June 2017 milestone Jul 11, 2017
@doxxx

This comment has been minimized.

Copy link

@doxxx doxxx commented Feb 12, 2019

Why does the Integrated Console even have to be visible? Why not start a PowerShell instance in the background for error-checking, etc.?

@scrthq

This comment has been minimized.

Copy link

@scrthq scrthq commented Feb 12, 2019

@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).

@doxxx

This comment has been minimized.

Copy link

@doxxx doxxx commented Feb 13, 2019

@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.

@TylerLeonhardt

This comment has been minimized.

Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Feb 14, 2019

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.

@doxxx

This comment has been minimized.

Copy link

@doxxx doxxx commented Feb 14, 2019

I hadn't realized that replicating the experience of the PowerShell ISE was the goal of the extension. That explains a lot. :)

@doxxx

This comment has been minimized.

Copy link

@doxxx doxxx commented Feb 14, 2019

I just tried the PowerShell Preview extension with the PSReadLine support enabled. Everything appears to be working correctly! Thanks so much for this!

@ClairelyClaire

This comment has been minimized.

Copy link

@ClairelyClaire ClairelyClaire commented Feb 17, 2019

Is Ctrl+Backspace supposed to be working with PSReadLine support in the latest preview build?

@rkeithhill

This comment has been minimized.

Copy link
Collaborator

@rkeithhill rkeithhill commented Feb 18, 2019

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
@ClairelyClaire

This comment has been minimized.

Copy link

@ClairelyClaire ClairelyClaire commented Feb 18, 2019

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.

@rkeithhill

This comment has been minimized.

Copy link
Collaborator

@rkeithhill rkeithhill commented Feb 18, 2019

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.

@ClairelyClaire

This comment has been minimized.

Copy link

@ClairelyClaire ClairelyClaire commented Feb 18, 2019

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.

@rkeithhill

This comment has been minimized.

Copy link
Collaborator

@rkeithhill rkeithhill commented Feb 18, 2019

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.

@Jaykul

This comment has been minimized.

Copy link

@Jaykul Jaykul commented Mar 19, 2019

Still. Waiting.

@JustinGrote

This comment has been minimized.

Copy link

@JustinGrote JustinGrote commented Mar 19, 2019

@Jaykul you can use it in the powershell preview module that was published, unless you're waiting on something else?

@rfoust

This comment has been minimized.

Copy link

@rfoust rfoust commented Mar 21, 2019

@JustinGrote The preview module doesn't show up as an available module on code-insiders, fwiw.

@TylerLeonhardt

This comment has been minimized.

Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Mar 21, 2019

@rfoust it should. They both pull from the same marketplace.

Search for "PowerShell" and look down the list. I remember seeing it about half way down the page.

@rfoust

This comment has been minimized.

Copy link

@rfoust rfoust commented Mar 21, 2019

Oh you're right, there it is. Not sure why I didn't see it last night. :)

@SydneyhSmith

This comment has been minimized.

Copy link
Collaborator

@SydneyhSmith SydneyhSmith commented Mar 27, 2019

Closing as PSReadLine is now available in the PowerShell Preview extension, tracking that PSReadLine is not available in the main PowerShell Extension here #1793

@iampeterdaniels

This comment has been minimized.

Copy link

@iampeterdaniels iampeterdaniels commented Feb 29, 2020

After updating to the non-preview powershell extension v 2020.1.0 and vscode 1.42.1, I have lost syntax highlighting in the integrated console. The actual code editor is working fine. Any ideas?

@JustinGrote

This comment has been minimized.

Copy link

@JustinGrote JustinGrote commented Feb 29, 2020

@iampeterdaniels non-preview extension doesn't have PSReadline, you have to use the preview extension for psreadline functionality (which includes syntax highlighting, special characters, etc.)

@iampeterdaniels

This comment has been minimized.

Copy link

@iampeterdaniels iampeterdaniels commented Feb 29, 2020

Thank you, Justin. Not sure why I thought the PSReadline 2.0 release somehow translated into it being in the non-preview extension.

@JustinGrote

This comment has been minimized.

Copy link

@JustinGrote JustinGrote commented Feb 29, 2020

@iampeterdaniels the current preview extension should roll into stable very soon, they're trying to target it for the PS7 release which will probably drop sometime this week or next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.