Closed
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
In Visual Studio Code, I have set Code Formatting settings to match my coding standards and have been using it successfully for a couple of years.
After an update I did a week or two ago, all of a sudden, when I save a file it reformats it, ignoring the settings:
- New Line After Close Brace
- New Line After Open Brace
- Open Brace On Same Line
NOTE: Formatting is done correctly if I run it from a PowerShell window:
R:\>Invoke-Formatter -ScriptDefinition 'try {
>> throw
>> }
>> catch {
>> Write-Host "foobar"
>> }'
try {
throw
}
catch {
Write-Host "foobar"
}
PowerShell Version
PS R:\packer> $PSVersionTable
Name Value
---- -----
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visual Studio Code Version
PS R:\packer> code --version
1.73.1
6261075646f055b99068d3688932416f2346dd3b
x64
Extension Version
PS R:\packer> code --list-extensions --show-versions | Select-String powershell
ms-vscode.powershell@2022.11.0
Steps to Reproduce
In Visual Studio Code:
- Open file that was saved before I did the update so it is formatted correctly.
- Make a very simple modification. (E.G. add a space somewhere.)
- Save the file.
The file is re-formatted ignoring the settings