May 3rd, 2022

Major update to the PowerShell Extension for Visual Studio Code

An updated version of our PowerShell extension is now available on the Visual Studio Code marketplace.

This update represents a complete overhaul of the core PowerShell engine of PowerShell Editor Services, intending to create a more reliable and stable user experience. This release represents nearly two years’ work, tracked in PSES #1295 and implemented in PSES #1459. It is our response to many issues opened by users over the last several years.

Thank you to all of the community members who opened issues which helped motivate this major update.

These major updates have also been tested over the last 6 months, in 13 releases of our PowerShell Preview extension for Visual Studio Code. A huge thank you to all of the community members who have tested these changes to the extension and have worked with us to polish the extension before releasing it through our stable channel.

For information on getting started with the PowerShell extension for Visual Studio Code refer to our documentation.

Highlights of the release

  • Rewrite of PowerShell pipeline execution with cancellable and ordered tasks
  • Loads of debugger reliability improvements
  • ReadKey fix (including better pasting on macOS and Linux, and a whole bunch of other bugs!)
  • Revamped PSHost implementation that reuses PowerShell’s built-in functionality wherever possible
  • Improved testing (in VS Code repo and PSES repo)
  • Improved completion logic (and more icons!)
  • Modernized built-in snippets
  • Improved user interface with built-in Codicons
  • Improved settings editor experience
  • Support debugging without a workspace
  • Support to debug other PowerShell processes and runspaces
  • DictionaryEntry displayed as key/value pairs in debugger
  • Removed PackageManagement module update prompt
  • Enabled resolution of an alias to its function definition
  • Fix formatting handlers and PSScriptAnalyzer loading
  • Performance improvements with better cancellation logic

For a complete list of changes please refer to our changelog.

More about the update

We began our work for this update with the following goals for the release to our stable extension

  • More reliable/stable experience overall
  • All tests are enabled and improved in both client (extension) and server (PSES) repositories
  • Feature parity with previous extension experience (or intentional depreciation of features)
  • No new moderate to high impact bugs

To accomplish these goals we focused on the threading model for the extension.

Previously the Integrated Console, the shell that is provided by the PowerShell extension, was run by setting threadpool tasks on a shared main runspace, and where LSP, Language Server Protocol, servicing was done with PowerShell idle events. This lead to overhead, threading issues and a complex implementation intended to work around the asymmetry between PowerShell as a synchronous, single-threaded runtime and a language server as an asynchronous, multi-threaded service.

Now, PowerShell Editor Services maintains its own dedicated pipeline thread, which is able to service requests similar to JavaScript’s event loop, meaning we can run everything synchronously on the correct thread. This prevents an entire class of race conditions, leading to more reliable and bug-free code. We also get more efficiency because we can directly call PowerShell APIs and code written in C# from this thread, without the overhead of a PowerShell pipeline.

This change has overhauled how we service LSP requests, how the Integrated Console works, how PSReadLine is integrated, how debugging is implemented, how remoting is handled, and a long tail of other features in PowerShell Editor Services.

Also, in making it, while 6,000 lines of code were added, we removed 12,000, for a more maintainable, more efficient and easier to understand extension backend.

What’s next for the extension

Beyond this release our intention is to remain focused on incremental improvements to the stability, reliability, and consistency of the extension. These next work items are enumerated in our GitHub Projects.

In particular we plan to focus on known issues with debugging and start-up.

Feedback and Support

While we hope the new implementation provides a much better user experience, there are bound to be issues. Please let us know if you run into anything.

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

PowerShell Team

Author

PM on the PowerShell team at Microsoft.

3 comments

Discussion is closed. Login to edit/delete existing comments.

  • Rob Cannon

    Congratulations on a hug release!

  • Christoph Hausner

    This is great news. I really hope this fixes two annoying issues I’ve had with the old extension, related to the PowerShell terminal. It would randomly open a new instance of the integrated PowerShell terminal and hide my previous one. Or it would show an error that the terminal had crashed and prompt me to open a new one.

  • Andrew Ducker

    Thank you!

    We’ve had long-running corruption issues when formatting on save, and this seems to have fixed them. VS Code is our standard IDE for PowerShell, and this makes the experience a lot smoother.