Skip to content

Formatting fails when parameter defaults are set to a statement #518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cohowap opened this issue Feb 28, 2017 · 3 comments
Closed

Formatting fails when parameter defaults are set to a statement #518

cohowap opened this issue Feb 28, 2017 · 3 comments
Labels
Issue-Bug A bug to squash.
Milestone

Comments

@cohowap
Copy link

cohowap commented Feb 28, 2017

System Details

  • Operating system name and version: Windows 10 Enterprise 10.0.14393
  • VS Code version: 1.9.1
  • PowerShell extension version: 0.9.0
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      5.1.14393.693
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.693
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

When I Format a document that contains a default value (that is actually a statement), formatting differs than if you do not have it (it is left aligned by an additional tab).

In this case, formatted for parameter "$Here" is incorrect, as is any code below it. Removing "$(throw ..)" fixes the issue.

function Do-Something {
  param(
    [Parameter(Position=0)]
    $Over = $(throw "The parameter -Over is required."),
  [Parameter(Position=1)]
  $Here = $(throw "The parameter -Here is required.")
)
}

Attached Logs

Not sure logs are required, this is reproducible on multiple systems. Just paste above and format document with and without the "$(throw ...)" part.

@kapilmb
Copy link

kapilmb commented Feb 28, 2017

This issue has been fixed in PowerShell/PSScriptAnalyzer#700 and the next release of the extension will contain the fix.

@daviwil daviwil added this to the 0.10.0 milestone Feb 28, 2017
@daviwil daviwil added the Issue-Bug A bug to squash. label Feb 28, 2017
@cohowap
Copy link
Author

cohowap commented Feb 28, 2017

@kapilmb Thanks! Sorry for duplicate issue, I didn't see that one. Feel free to close, or I can.

@daviwil
Copy link
Contributor

daviwil commented Feb 28, 2017

Probably wasn't easy to find while searching due to its title. I'll close this now, let us know if you still see the issue after the 0.10.0 update. Should be out in a few days. Thanks!

@daviwil daviwil closed this as completed Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

3 participants