Skip to content

Auto-formatting incorrectly places an opening curly bracket if there is a comment on the previous line #1082

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
exchange12rocks opened this issue Nov 1, 2017 · 2 comments
Labels

Comments

@exchange12rocks
Copy link

System Details

Windows 10 64-bit

code -v:
1.17.2
b813d12980308015bcd2b3a2f6efa5c810c33ba5

$pseditor.EditorServicesVersion:
Major  Minor  Build  Revision
-----  -----  -----  --------
1      5      0      0

code --list-extensions --show-versions:
jasonn-porch.gitlab-mr@1.3.0
ms-mssql.mssql@1.2.0
ms-vscode.PowerShell@1.5.0

$PSVersionTable:
Name                           Value
----                           -----
PSVersion                      5.1.16299.19
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.19
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I am experiencing a problem with curly brackets auto-formatting in if and for blocks (could be other blocks affected as well): If there is a comment on a line where the block starts and the opening curly bracket is on the next line, the bracket is placed on the first line, after the comment, which breaks the block.

if ($true) # comment
{
    echo 'OK'
}

foreach ($a in $b) #comment
{
    echo $a
}

Expected Result

if ($true) { # comment
    echo 'OK'
}

foreach ($a in $b) { #comment
    echo $a
}

Actual Result

if ($true) # comment {
    echo 'OK'
}

foreach ($a in $b) #comment {
    echo $a
}
@MRWeather
Copy link

I opened an issue for this a while ago, it got moved here for some reason:
PowerShell/PSScriptAnalyzer#826

Just want to avoid duplicated efforts.

@exchange12rocks
Copy link
Author

I agree - this is a duplicate of PowerShell/PSScriptAnalyzer#826

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants