Skip to content

Regression: Powershell extension incorrectly indents code upon formatting #2228

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
MarkKharitonov opened this issue Oct 4, 2019 · 2 comments
Labels
Resolution-Duplicate Will close automatically.

Comments

@MarkKharitonov
Copy link

System Details

### VSCode version: 1.38.1 b37e54c98e1a74ba89e03073e5a3761284e3ffb0 x64

### VSCode extensions:
aaghabeiki.gitdiffer@0.0.3
akamud.vscode-theme-onelight@2.1.0
amos402.scope-bar@0.2.1
axlan.multiline-find-and-replace@0.0.1
cake-build.cake-vscode@0.12.0
DotJoshJohnson.xml@2.5.0
eamodio.gitlens@10.0.1
GrapeCity.gc-excelviewer@2.1.32
Hyzeta.vscode-theme-github-light@7.9.2
jbockle.jbockle-format-files@3.0.0
jmrog.vscode-nuget-package-manager@1.1.6
ms-azuretools.vscode-azurefunctions@0.18.1
ms-mssql.mssql@1.6.0
ms-vscode.azure-account@0.8.4
ms-vscode.csharp@1.21.4
ms-vscode.powershell@2019.9.0
ms-vscode.vs-keybindings@0.2.0
qub.qub-msbuild@0.6.3
tintoy.msbuild-project-tools@0.2.55
Tyriar.shell-launcher@0.3.0
yzhang.markdown-all-in-one@2.4.2


### PSES version: 1.13.0.0

### PowerShell version:

Name                           Value                                                                                                                           
----                           -----                                                                                                                           
PSVersion                      5.1.17763.592                                                                                                                   
PSEdition                      Desktop                                                                                                                         
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                         
BuildVersion                   10.0.17763.592                                                                                                                  
CLRVersion                     4.0.30319.42000                                                                                                                 
WSManStackVersion              3.0                                                                                                                             
PSRemotingProtocolVersion      2.3                                                                                                                             
SerializationVersion           1.1.0.1                                                                                                                         

Issue Description

Consider the following ps code:

function Get-BuildTelemetry([Parameter(Mandatory)]$Build)
{
    @{
        tasks  = (Invoke-RestMethod $Build._links.timeline.href -UseDefaultCredentials).records | Where-Object { 
            $_.type -eq 'task'
        } | Sort-Object 'startTime'
        dimensions = @{
            id = $Build.id
        }
    }
}

Formatting the code transforms it to:

function Get-BuildTelemetry([Parameter(Mandatory)]$Build)
{
    @{
        tasks  = (Invoke-RestMethod $Build._links.timeline.href -UseDefaultCredentials).records | Where-Object { 
            $_.type -eq 'task'
        } | Sort-Object 'startTime'
    dimensions = @{
        id = $Build.id
    }
}
}

Which is wrong.

My user settings are:

{
    "powershell.codeFormatting.openBraceOnSameLine": false,
    "powershell.codeFormatting.whitespaceBeforeOpenBrace": false,
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true
}

I am forced to disable auto formatting at all.

@ghost ghost added the Needs: Triage Maintainer attention needed! label Oct 4, 2019
@corbob
Copy link
Contributor

corbob commented Oct 5, 2019

Looks like this should be fixed in next release of stable: PowerShell/PowerShellEditorServices#1050

@rjmholt rjmholt added Resolution-Duplicate Will close automatically. and removed Needs: Triage Maintainer attention needed! labels Oct 5, 2019
@ghost
Copy link

ghost commented Oct 6, 2019

This issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes.

@ghost ghost closed this as completed Oct 6, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Duplicate Will close automatically.
Projects
None yet
Development

No branches or pull requests

3 participants