Releases: PowerShell/vscode-powershell
v1.4.0
New HTML content view commands enabling custom UI tabs
You can now show editor tabs with custom HTML-based UI by using the new HTML content view commands! This is the first step toward UI extensions for VS Code written in PowerShell.
Here's an example:
$view = New-VSCodeHtmlContentView -Title "My Custom View" -ShowInColumn One
Set-VSCodeHtmlContentView -View $view -Content "<h1>Hello world!</h1>"
Write-VSCodeHtmlContentView $view -Content "<b>I'm adding new content!</b><br />"
And here's the result:
Check out the cmdlet help for the following commands to learn more:
New-VSCodeHtmlContentView
Show-VSCodeHtmlContentView
Close-VSCodeHtmlContentView
Set-VSCodeHtmlContentView
Write-VSCodeHtmlContentView
Since this is a first release, we've restricted the use of JavaScript inside of the HTML. We will add this capability in a future release!
Code formatting setting presets for common styles
We've now added code formatting presets for the most common code style conventions used in the PowerShell community. You can now set the powershell.codeFormatting.preset
setting to one of the following presets:
-
OTBS - Known as the "One True Brace Style". Causes
else
,catch
, and other keywords to be "cuddled", keeping them on the same line as the previous closing brace:if ($var -eq $true) { # Do the thing } else { # Do something else }
-
Stroustrup - Causes beginning curly braces to be placed on the same line as the statement:
if ($var -eq $true) { # Do the thing } else { # Do something else }
-
Allman - All curly braces are preceded by a newline:
if ($var -eq $true) { # Do the thing } else { # Do something else }
-
Custom - Allows full customization of the code formatting settings.
In addition, code formatting now respects your editor.insertSpaces
and editor.tabSize
settings!
Debugging in a temporary PowerShell Integrated Console
We've added the ability to debug your PowerShell code in a temporary PowerShell Integrated Console so that you have a fresh runspace and PowerShell process each time you hit F5!
This setting is necessary if you are developing with PowerShell 5 classes or modules using .NET assemblies because .NET types cannot be reloaded inside of the same PowerShell process. This new setting
saves you from reloading your PowerShell session each time you debug your code!
You can configure this behavior in two ways:
-
Use the
launch.json
configuration parametercreateTemporaryIntegratedConsole
:{ "type": "PowerShell", "request": "launch", "name": "PowerShell Launch Current File in Temporary Console", "script": "${file}", "args": [], "cwd": "${file}", "createTemporaryIntegratedConsole": true },
-
Configure the setting
powershell.debugging.createTemporaryIntegratedConsole
:"powershell.debugging.createTemporaryIntegratedConsole": true,
The default value for these settings is false
, meaning that the temporary console behavior is opt-in.
Configuring the user or workspace setting will cause all debugging sessions to be run in a temporary Integrated Console so it's useful if you would prefer this to be the default behavior. The launch.json
setting overrides the user setting so you can always customize the behavior for a specific launch configuration.
NewFile() API and Out-CurrentFile command
You can now create a new untitled file from within the Integrated Console by using the $psEditor.Workspace.NewFile()
command! Also, you can send the formatted output of any PowerShell command to the current file by using the Out-CurrentFile
command:
Get-Process | Out-CurrentFile
Special thanks to Doug Finke for the contribution!
Other fixes and improvements
v1.3.2
Fixes and improvements
-
PowerShell/vscode-powershell#864 - Improved the visibility of hyphen characters on the currently edited line in the PowerShell ISE theme (thanks Stefan Stranger!)
-
PowerShell/vscode-powershell#857 - Typing a new function into a file no longer causes the language server to crash
-
PowerShell/vscode-powershell#855 - "Format Document" no longer hangs indefinitely
-
PowerShell/vscode-powershell#859 - Language server no longer hangs when opening a Pester test file containing dot-sourced script references
-
PowerShell/vscode-powershell#856 - CodeLenses for function definitions no longer count the definition itself as a reference and shows "0 references" when there are no uses of that function
-
PowerShell/vscode-powershell#838 - Right-clicking a debugger variable and selecting "Add to Watch" now has the desired result
-
PowerShell/vscode-powershell#837 - Debugger call stack now navigates correctly to the user's selected stack frame
-
PowerShell/vscode-powershell#862 - Terminating errors in the language server now close the Integrated Console immediately and prompt the user to restart the session
-
PowerShell/PowerShellEditorServices#505 - Added improved cmdlet help in the PowerShellEditorServices.Commands module
-
PowerShell/PowerShellEditorServices#509 - Importing the PowerShellEditorServices.Commands module no longer causes errors to be written about missing help languages
v1.3.1
Fixes and improvements
-
#850 -
Fixed an issue where lower-cased "describe" blocks were not identified by
the CodeLens feature. -
#851 -
Fixed an issue where the language server would hang when typing out a describe
block. -
#852 -
Fixed an issue where Pester test names would not be detected correctly when
other arguments like -Tags were being used on a Describe block.
v1.3.0
CodeLens for running and debugging Pester tests
We've added two new CodeLens actions that show up above Describe blocks in your Pester tests, "Run tests" and "Debug tests". By clicking one of these CodeLenses, your tests will be executed in the Integrated Console with the debugger attached. You can now set breakpoints and quickly debug a portion of your test script:
CodeLens support for finding references of a function or cmdlet
We've also added CodeLenses for showing the number of references for a function or cmdlet that is defined in a script. If you click this CodeLens, the references pane will appear so that you can navigate through all of the references:
We will add CodeLens support for PowerShell 5+ classes and class methods in a future update!
Document symbol support for Pester tests
We've also added document symbol support for Pester tests so that you can easily navigate among the Describe, Context, and It blocks in large Pester script files:
New PowerShell ISE theme
We now include a new color theme that tries to provide a faithful interpretation of the PowerShell ISE's style, including a blue console background! To use this theme open the Command Palette (Ctrl+Shift+P), run the "Preferences: Color Theme" command, then select "PowerShell ISE".
This is a first attempt at making this happen so give us feedback if you think that the colors can be improved! Super huge thanks to Matt McNabb for putting this together!
New cmdlets inside the Integrated Console
Thanks to new PowerShell Editor Services co-maintainer Patrick Meinecke, we've gained a new set of useful commands for interacting with the $psEditor APIs within the Integrated Console:
- Find-Ast
- Get-Token
- ConvertFrom-ScriptExtent
- ConvertTo-ScriptExtent
- Set-ScriptExtent
- Join-ScriptExtent
- Test-ScriptExtent
- Import-EditorCommand
This should also resolve the issues some people were seeing when we tried to load the unsigned temporary script containing Register-EditorCommand
on machines with an AllSigned execution policy (#784).
Fixes and improvements
- #827 - Fixed an issue where an Output panel will appear with an error when you close the PowerShell Integrated Terminal
v1.2.1
Fixes and improvements
-
PowerShell/PowerShellEditorServices#478 - Dynamic comment help snippets now generate parameter fields correctly when
<#
is typed above aparam()
block. -
#808 - An extra
PS>
is no longer being written to the Integrated Console for some users who have custom prompt functions. -
#813 - Finding references of symbols across the workspace now properly handles inaccessible folders and file paths
-
#810 -
$psEditor.GetEditorContext()
now doesn't throw exceptions when in an untitled file -
#807 - The users's previously selected PowerShell session type is now retained when running the "PowerShell: Restart Current Session" command.
-
#821 - Note properties on PSObjects are now visible in the debugger's Variables view
v1.2.0
Dynamic comment-based help snippets now work inside functions (#763)
You asked for it, you got it! Dynamic comment-based help snippets now work inside function definitions, both above the param()
block and at the end of the function body:
NOTE: There is an issue where parameter sections don't get generated inside of a function with a [CmdletBinding()]
attribute. This is being tracked at PowerShell/PSScriptAnalyzer#768.
Session menu now contains entries for PowerShell Core installations on Windows (#794)
It's now much easier to switch between Windows PowerShell and PowerShell Core installs on Windows. When you run the "PowerShell: Show Session Menu" command or click the PowerShell version indication in the status bar you'll now see PowerShell Core entries in the menu:
Improved PSScriptAnalyzer marker display and suppression snippets (#781) and (#783)
The green squiggle markers you receive from PSScriptAnalyzer now include the name of the corresponding rule in their description:
This is really helpful with the new rule suppression snippets contributed by Jos Verlinde! You can access them by typing suppress-
and selecting one of the suppression snippet options:
New built-in Pester problem matcher (#798)
We now include a built-in problem matcher for Pester test output so that you don't need to define one in your tasks.json
file any longer! You can reference the built-in problem matcher in your test tasks by using the name $pester
:
{
"taskName": "Test",
"suppressTaskName": true,
"isTestCommand": true,
"showOutput": "always",
"args": [ "Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true}" ],
"problemMatcher": "$pester"
}
NOTE: There is an issue with problem matchers when using the new 2.0.0
version of VS Code's task runner. Pester errors may show up multiple times in the Problems panel. This issue is being tracked at #797.
Other fixes and improvements
-
#710 - Variable definitions can now be found across the workspace
-
#771 - Improved dynamic comment help snippet performance in scripts with many functions
-
#786 - Running the "Show Integrated Console" command will now start the extension if it isn't already started
-
#774 - Pressing Enter now causes custom prompt functions to be fully evaluated
-
#770 - Fixed issue where custom prompt function might be written twice when starting the integrated console
-
#767 - Fixed placeholder navigation for many built-in snippets
-
#782 - Fixed extension host crash when restarting the PowerShell session
-
#737 - Fixed hangs and high CPU when restarting or switching between PowerShell sessions
-
#777 - Changed "Starting PowerShell" message to clearly indicate that we're in the PowerShell Integrated Console
v1.1.0
New dynamic snippet for adding comment-based help (#748)
We've added a really cool new feature that enables you to create comment-based help blocks with ease! When you've defined a function in a PowerShell script file, you can now start typing a comment block above the function definition and it will be completed for you:
This comment block works like a snippet, allowing you to tab through the fields to quickly add documentation for the parts you care about.
This is a first pass for this feature and we plan to do more with it in the future. Please feel free to file feature requests for anything else you'd like to see!
Breakpoints hit in the Integrated Console now activate the debugger UI (#619)
In previous releases it was necessary to start the "PowerShell Interactive Session" debugging configuration before you could run a command or script from the Integrated Console and hit breakpoints in the editor UI. We've just removed this limitation!
Now when you set a breakpoint using Set-PSBreakpoint
and run a script or command in the Integrated Console, the debugger UI now gets activated:
Note that breakpoints set in the Integrated Console still do not show up
in the editor UI; this requires changes to VS Code that we'll be contributing for their next feature release.
Improved output when loading profile scripts (#663 and #689)
We now write the errors and Write-Output calls that occur while loading profile scripts so that it's easier to diagnose issues with your profile scripts. This fix will help us identify the things missing from the Integrated Console which cause your profile scripts to fail (like the current lack of a PrivateData object for setting console colors).
Please feel free to file issues for anything that causes your profile scripts to throw errors when they get loaded!
Other fixes and improvements
-
#751 - Removed keybinding for the "Find PowerShell Modules from the Gallery" command because it conflicts with VS Code's default "Format Selection" keybinding.
-
#739 - Fixed wording of PowerShell extension commands to have consistent capitalization. Thanks to @AndySchneiderDev for the contribution!
v1.0.0
We are excited to announce that we've reached version 1.0! For more information, please see the official announcement on the PowerShell Team Blog.
New script argument UI when debugging (#705)
You can now set PowerShell debugger configurations to prompt for arguments to be passed to your script when it is executed. This is configured using the new ${command:SpecifyScriptArgs}
configuration variable in launch.json
:
{
"type": "PowerShell",
"request": "launch",
"name": "PowerShell Launch DebugTest.ps1 w/Args Prompt",
"script": "${workspaceRoot}/DebugTest.ps1",
"args": [ "${command:SpecifyScriptArgs}" ],
"cwd": "${file}"
}
When you launch this configuration you will see a UI popup asking for arguments:
You can type your arguments to the script as you would in PowerShell:
-Count 5
In future executions of this configuration, you will be presented with the arguments you typed the last time you ran it so that you can easily edit them and test variations!
New hash table alignment formatting rule (#672)
We've added a new code formatting rule that automatically aligns the equal sign in assignments of keys in hash tables or DSC configurations. It also works with nested hash tables! Here's a simple example:
Before
$formatTest = @{
Apple = 4
Tangerine = @{
Orange = 2
CornflowerBlue = 6
}
Banana = 3
}
After
$formatTest = @{
Apple = 4
Tangerine = @{
Orange = 2
CornflowerBlue = 6
}
Banana = 3
}
This formatting rule is enabled by default but can be disabled with the following setting:
"powershell.codeFormatting.alignPropertyValuePairs": false
Added basic module-wide function references support
In the past, finding the references or definition of a function in FileA.ps1
only worked if FileA.ps1
had an explicit dot-source invocation of FileB.ps1
. We have removed this limitation so that you can now find definitions and references of any function across all the script files in your project folder! This is especially useful if you write PowerShell modules where all of the source files are dot-sourced inside of the .psm1 file.
This new implementation is very basic and may give unexpected results, so please file an issue on GitHub if you get a result you did not expect!
Other integrated console and debugger improvements
-
Fixed #698 - When debugging scripts in the integrated console, the cursor position should now be stable after stepping through your code! Please let us know if you see any other cases where this issue appears.
-
Fixed #626 - Fixed an issue where debugging a script in one VS Code window would cause that script's output to be written to a different VS Code window in the same process.
-
Fixed #618 - Pressing enter on an empty command line in the Integrated Console no longer adds the empty line to the command history.
-
Fixed #617 - Stopping the debugger during a prompt for a mandatory script parameter no longer crashes the language server.
-
Fixed PowerShellEditorServices #428 -
Debugger no longer hangs when you stop debugging while an input or choice prompt is active in the integrated console.
v0.12.2
-
Fixed #662 - Changed usage of
$env:PSMODULEPATH
to$env:PSModulePath
to conform to a recent change in PowerShell 6 (PowerShell/PowerShell#3255) which makes the casing ofPSModulePath
consistent between Windows and the *NIX platforms.NOTE: This is a breaking change for PowerShell extension users on Linux and macOS
If you are using PowerShell 6.0.0-alpha.17 or lower you will need to upgrade to 6.0.0-alpha.18.
-
Fixed #645 - "Go to Definition" or "Find References" now work in untitled scripts without crashing the session
-
Fixed #632 - Debugger no longer hangs when launched while PowerShell session is still initializing
-
Fixed #655 - Fixed an issue with current working directory being set incorrectly when debugging untitled script files
-
Fixed PowerShellEditorServices #430 - Resolved occasional IntelliSense slowness by preventing the implicit loading of the PowerShellGet and PackageManagement modules. This change will be reverted once a bug in PackageManagement is fixed.
-
Fixed PowerShellEditorServices #427 - Fixed an occasional crash when requesting editor IntelliSense while running a script in the debugger
-
Fixed PowerShellEditorServices #416 - Cleaned up errors that would appear in the
$Errors
variable from the use ofGet-Command
andGet-Help
in IntelliSense results