You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make sure you are able to repro it on the latest released version
Perform a quick search for existing issues to check if this bug has already been reported
Steps to reproduce
functionTest {
param(
[scriptblock] $Test,
[switch] $Test1,
[switch] $Test2
)
if ($Test1) {
Write-Host"Test me 1"
}
if ($Test2) {
Write-Host'Test me 2'
}
}
Test {
} -Test1 -Test2
Try to format this and notice code gets removed. It seems if -Test1 is more then 1 space away from closing bracket things get sideways. This code executes properly so I would say it's valid PowerShell
Output:
functionTest {
param(
[scriptblock] $Test,
[switch] $Test1,
[switch] $Test2
)
if ($Test1) {
Write-Host"Test me 1"
}
if ($Test2) {
Write-Host'Test me 2'
}
}
Te-Test1 -Test2
It's related to "powershell.codeFormatting.whitespaceBetweenParameters": true
Expected behavior
Remove too many spaces, leave my code alone :-)
Actual behavior
Removes a lot more
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Make sure you are able to repro it on the latest released version
Perform a quick search for existing issues to check if this bug has already been reported
Steps to reproduce
functionTest {
param(
[scriptblock] $Test,
[switch] $Test1,
[switch] $Test2
)
if ($Test1) {
Write-Host"Test me 1"
}
if ($Test2) {
Write-Host'Test me 2'
}
}
Test {
} -Test1 -Test2
Try to format this and notice code gets removed. It seems if -Test1 is more then 1 space away from closing bracket things get sideways. This code executes properly so I would say it's valid PowerShell
Output:
functionTest {
param(
[scriptblock] $Test,
[switch] $Test1,
[switch] $Test2
)
if ($Test1) {
Write-Host"Test me 1"
}
if ($Test2) {
Write-Host'Test me 2'
}
}
Te-Test1 -Test2
It's related to "powershell.codeFormatting.whitespaceBetweenParameters": true
Expected behavior
Remove too many spaces, leave my code alone :-)
Actual behavior
Removes a lot more
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Thanks @PrzemyslawKlys this issue looks like a duplicate of issue #1561 unfortunately the formatter needs some updating, thanks for supplying the detailed info and re-pro
Before submitting a bug report:
Steps to reproduce
Try to format this and notice code gets removed. It seems if -Test1 is more then 1 space away from closing bracket things get sideways. This code executes properly so I would say it's valid PowerShell
Output:
It's related to
"powershell.codeFormatting.whitespaceBetweenParameters": true
Expected behavior
Remove too many spaces, leave my code alone :-)
Actual behavior
Removes a lot more
If an unexpected error was thrown then please report the full error details using e.g.
$error[0] | Select-Object *
Environment data
The text was updated successfully, but these errors were encountered: