r/PowerShell • u/daviwil PowerShell ISE Code Engineer • Mar 15 '17
Just released v0.10.0 of the PowerShell extension for Visual Studio Code with an integrated console experience like the ISE!
https://twitter.com/daviwil/status/8418005801084477442
u/dastylinrastan Mar 15 '17
Awesome work David, thanks for putting in some blood and sweat on this and closing a lot of those last-mile ISE gaps.
1
2
u/AdmiralCA Mar 15 '17 edited Mar 15 '17
David - brilliant work as always!
Not sure if this bug goes to you or to the Code team but....
(testing on Win10) When hitting the trashcan on on the Integrated PowerShell Console, it would pop an error saying that it closed incorrectly, and ask if I wanted to restart the session.
Thoughts?
Edit: In regards to a question now deleted - I realized that the session wasn't viewing the file as PowerShell, and therefore wouldn't give me the Integrated Console as an option for a terminal.
2
u/daviwil PowerShell ISE Code Engineer Mar 15 '17
That restart prompt is mine, the idea there is that if the language server crashes it should prompt the user to restart for the sake of convenience. Are there cases when you want to close the integrated console entirely?
2
u/AdmiralCA Mar 15 '17
I guess my use case is for "wiping the slate clean". I understand the idea of crash/notify, but I wouldn't expect it from a button press.
2
u/zenmaster24 Mar 15 '17
cool - does this mean vscode supports multiple terminals now? i dont have to edit my preferences to set the default to powershell anymore?
edit - i use vscode with python and bash shells in the terminal as well (win 10 wsl for bash)
1
u/daviwil PowerShell ISE Code Engineer Mar 15 '17
You don't need to set your default terminal for PowerShell if all you want is to use the Integrated Console, I'm in control of which PowerShell gets launched in that case. If you've never configured your default terminal setting and you open a .ps1, the PowerShell Integrated Console will open with the correct PowerShell path based on your platform.
Does that make sense?
1
u/Emiroda Mar 15 '17
You still need to set a default terminal in settings.json.
1
u/daviwil PowerShell ISE Code Engineer Mar 15 '17
Not for the Integrated Console, it runs powershell.exe automatically without configuration.
1
u/Emiroda Mar 15 '17
That's true, but if he wants bash or python shell, he needs to specify it, correct?
3
u/daviwil PowerShell ISE Code Engineer Mar 15 '17
Yep, absolutely. You can use /u/Tyriar's vscode-shell-launcher to make this easier:
2
u/zenmaster24 Mar 16 '17
wow this is exactly what i wanted vscode to do natively! thankyou so much for showing me this exists!
2
u/Emiroda Mar 15 '17
It's fucking amazing, let me tell you that.
I have one single feature request: Color coding in the terminal via PSReadline :)
3
u/daviwil PowerShell ISE Code Engineer Mar 15 '17
Yep, PSReadline support is coming but it will require a bit of work. Might take a couple more months, but hopefully less.
4
u/joerod Mar 15 '17
Very happy with this. I like VS code but there were a few things missing that kept me using ISE for PowerShell development. Seems like your closing the gap with this release.
1
u/Swarfega Mar 15 '17
Great job on this.
Is there a way to cycle through matching cmdlets via autocomplete (tab) rather than being like Unix style as it is now and just autocompletes the first matching cmdlet?
1
u/daviwil PowerShell ISE Code Engineer Mar 15 '17
If you keep pressing tab, it cycles through the completions for the current word. Maybe you're suggesting something different?
2
u/Swarfega Mar 15 '17
Yeah so if i type Get-C then keep pressing tab in the ISE it cycles through all available cmdlets that begin with Get-C. VSCore just autocompletes the first cmdlet it matches.
2
u/daviwil PowerShell ISE Code Engineer Mar 15 '17
Oh, you mean in the editor, not the console, right? I'll look into that, there must be a way to do it now.
2
u/Swarfega Mar 15 '17
Sorry yes the editor. You can change how this behaves in PSReadLine.
Set-PSReadlineOption -EditMode EmacsWhen you press tab twice is like Unix where it displays all cmdlets that match.
Set-PSReadlineOption -EditMode WindowsIs what we're used to in PowerShell where it cycles though matching cmdlets.
2
u/Teh_Fonz Mar 15 '17
Thank you! Recently started using Powershell in VSC and love the editing capabilities but still go back to ISE for the integrated console. Hopefully this means I can to stick with one scripting tool!
1
1
1
1
u/soopaman20 Mar 15 '17
I haven't opened ISE today since this release. I love it and look forward to further changes for the niggle things. Got so much to play with.
Top work u/daviwil
1
1
1
21
u/daviwil PowerShell ISE Code Engineer Mar 15 '17
New interactive console experience
We are excited to provide you with the first release of our new interactive console experience! When you open up a PowerShell script file, you will be greeted with a new VS Code integrated terminal window called "PowerShell Integrated Console"
integrated console screenshot
In this console you will have an experience that falls somewhere between the PowerShell ISE and the PowerShell console host:
Tab completion of commands and their parameters
Basic command history, accessed using the up/down arrow keys
The
pseditcommand opens existing files in an editor panePressing <kbd>F8</kbd> in an editor pane runs the current line or selection in the console
Native applications like
gitare fully supportedScript debugging shares the same console session with the editor for a true ISE-like debugging experience
It even works with your fancy prompt function if configured in your VS Code profile (
$HOME\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1):custom prompt screenshot
The integrated console is supported on PowerShell v3 through v6 and works on Linux and macOS with PowerShell Core. By default you don't have to configure which PowerShell to run, we will pick an appropriate default based on your platform. If you'd like to choose a different install of PowerShell you can always change the
powershell.developer.powerShellExePathsetting.Keep in mind that this is the first release for this feature and there are bound to be issues and missing functionality. Please feel free to file GitHub issues for any bugs or feature requests!
Known Issues and Limitations
#535 PSReadline is currently not supported in the integrated console. We will enable this in a future release.
#534 Integrated console prompt is not restarted when you stop the debugging of a local runspace in another process. This will be addressed soon in a patch update.
#533 Backspace key does not work in the integrated console on Linux and macOS. The workaround for now is to use <kbd>Ctrl+H</kbd> instead of the Backspace key. This will be addressed soon in a patch update.
#536 Integrated console sometimes does not have a scrollbar at startup. The workaround is to resize the width of the VS Code window slightly and the scrollbar will appear. This will be addressed soon in a patch update.
Get-Credential and PSCredential support
Now that we have the integrated console, we have added support for the
Get-Credentialcmdlet,Read-Host -AsSecureString, and any input prompt of typeSecureStringorPSCredential. When you run any of these cmdlets you will be prompted inside the integrated console:credential screenshot
Code formatting improvements
We now support VS Code's
editor.formatOnTypesetting so that your code gets formatted as you type! Formatting will be triggered when you press Enter or the closing curly brace character}.Based on your feedback, we've also added new code formatting options, all of which are turned on by default:
powershell.codeFormatting.newLineAfterCloseBrace- Causes a newline to be inserted after a closing brace in multi-line expressions like if/elsepowershell.codeFormatting.whitespaceBeforeOpenBrace- Causes whitespace to be inserted before an open brace likeForeach-Object {powershell.codeFormatting.whitespaceBeforeOpenParen- Causes whitespace to be inserted before an open parentheses likeif (powershell.codeFormatting.whitespaceAroundOperator- Causes whitespace to be inserted around operators like=or+powershell.codeFormatting.whitespaceAfterSeparator- Causes whitespace to be inserted around separator characters like;and,powershell.codeFormatting.ignoreOneLineBlock- Single-line expressions, like small if/else statements, will not be expanded to multiple lines.We've also made many improvements to the performance and stability of the formatter.
Debugging improvements
We've added a new configuration for debugging your Pester tests. By default it merely runs
Invoke-Pesterat the workspace path, but you can also edit the configuation to add additional arguments to be passed through.We've also added support for column breakpoints. Now you can set a breakpoint directly within a pipeline by placing your cursor at any column on a line and running the
Debug: Column Breakpointcommand:column breakpoint screenshot
For the latest PowerShell Core release (6.0.0-alpha.17), we have also added the ability to step into ScriptBlocks that are executed on another machine using
Invoke-Command -Computer.Set a breakpoint on an
Invoke-Commandline and then once it's hit:Invoke-Command screenshot
Press
F11and you will step into the ScriptBlock. You can now continue to use "step in" and trace the ScriptBlock's execution on the remote machine:remote script listing screenshot
Note that you cannot currently set breakpoints in the script listing file as this code is being executed without an actual script file on the remote machine.
Other fixes and improvements
Fixed #427 - The keybinding for "Expand Alias" command has been changed to <kbd>Shift+Alt+E</kbd>
Fixed #519 - Debugger hangs after continuing when watch expressions are set
Fixed #448 - Code formatter should keep indentation for multi-line pipelines
Fixed #518 - Code formatter fails when dollar-paren
$()expressions are usedFixed #447 - Code formatter crashes when run on untitled documents