We are excited to announce that we have released a major update to the PowerShell extension for Visual Studio Code. This release contains months of architectural work that first shipped in our PowerShell Preview extension in November of 2019, along with incremental bug fixes in the intervening months. If you are new to Visual Studio Code this article is helpful for getting started. If you already use Visual Studio Code with the PowerShell extension, read on to find out what is new.
ISE Compatibility Module
We took the documentation from our “How to replicate the ISE experience in Visual Studio Code” doc and turned it into a switch to make the process of using Visual Studio code more familiar for Windows PowerShell ISE users.
This work can largely be seen in:
vscode-PowerShell #2335 –
Add editor command
PowerShell: Enable/Disable ISE Mode for ISE emulation in VS Code. (Thanks @Corbob)
Syntax Highlighting, Multi-Line Editing and Back Search in the Integrated Console
PSReadLine, the module that provides the powerful command line-editing experience you are used to in the PowerShell console
(including syntax highlighting, multi-line editing and, back search), is now available in the Visual Studio Code integrated console across all operating systems. Full PSReadLine support has long been at the top of our list for feature requests.
It has also been among our most difficult problems to solve because at its core it also required architectural changes in how the PowerShell extension manages threading and runspaces. The additional challenge of trying to support both legacy versions of PowerShell and a range of platform distributions has caused this problem to continually be delayed. In January of 2019 we released a Preview version of the PowerShell extension which was built on .NET Standard thereby enabling us to support PSReadLine in the integrated console for Windows users on PowerShell Version 5.1 and above.
With PowerShell 7 delivering a fix in .NET Core 3.1 for the way POSIX terminal APIs are handled when starting new processes, we are finally able to move the PSReadLine support currently available in the PowerShell Preview extension into the stable PowerShell extension with support across platform distributions.
This work can largely be seen in:
PowerShellEditorServices #672 –
PSReadLine integration (Thanks @SeeminglyScience!)
Our number one user request for the PowerShell editing experience in Visual Studio Code is to improve the stability of the editor and debugger. Long-standing constraints in the original design of the PowerShell extension made it difficult to improve its robustness through incremental changes. Instead, over a period of six months we prioritized work to re-architect the extension with an emphasis on stability. Omnisharp’s architecture is more robust meaning that bugs that might once have been crashes will now be caught and logged. By leveraging this library we were able to greatly simplify our code and are now more compliant with language server protocol.
Ultimately, we believe that these changes will significantly reduce the number crashes of the extension and improve the performance overall. Other features of the Omnisharp port include asynchronous message handling for increase in performance, CodeLens requests no longer depending on running PowerShell (greatly improving Intellisense responsiveness), and formatting handled directly by the language server.
This work can be seen in:
PowerShellEditorServices #1056 –
Re-architect PowerShell Editor Services to use the Omnisharp LSP platform.
A number of other features have been available in the PowerShell Preview extension that are now available in the PowerShell extension.
- PowerShellEditorServices #1187 – Upgrade built-in PSReadLine to 2.0.0 GA.
- vscode-PowerShell #2316 –
powershell.integratedConsole.forceClearScrollbackBuffersetting to enable
Clear-Hostto clear scrollback buffer.
- PowerShellEditorServices #1108 –
Clear the terminal via the LSP message
- vscode-PowerShell #1945 –
Edit snippets to support $TM_SELECTED_TEXT (Thanks @travis-c-lagrone!)
- vscode-PowerShell #1928 –
Add RunCode command for CodeLens providers
- PowerShellEditorServices #877 –
Add filtering for CodeLens and References (Thanks @glennsarti!)
- vscode-powershell #1398 –
Improve path auto-completion (Thanks @rkeithhill!)
For a full list of changes see our detailed changelog.
Support for PSReadLine in the PowerShell extension Integrated Console depends on changes made in PSReadLine 2.0, which does not support PowerShell versions 3 and 4. In turn, we also made the difficult decision to no longer support PowerShell 3 and 4 in future updates of the extension. In making this decision we analyzed the use of these PowerShell versions and found that approximately 1% of PowerShell session in VSCode use one of these versions. In order to accommodate these use cases we will shipped a final stable version of the extension with PowerShell version 3 and 4 support which can continue to be used (2020.01). To use this version of the extension the user will still install the PowerShell extension through the VSCode marketplace. They will then need to use the extension settings to select their desired version.
This breaking change can be seen in:
PowerShellEditorServices #741 –
Migrate to netstandard2.0 and PSStandard
We also made the decision to close over a number of APIs that were not designed for public exposure.
For more detailed information on this decision check out PowerShellEditorServices #1183.
What’s going to happen to the Preview Extension?
Going forward we will use preview as a vNext of our stable extension, so a preview release will take bugfixes and become the next stable release. After this release we plan to continue to address other outstanding issues in the extension, and use the PowerShell Preview extension as a means of increasing our release cadence.
Feedback and Support
Once we make these releases we will continue to make investments in the PowerShell editing experience. If you encounter any issues with the PowerShell extension in Visual Studio Code or have feature requests, the best place to get support is through our GitHub repository.
Sydney Smith, Robert Holt, Tyler Leonhardt