Skip to content

Formatter should check for end-of-line comment when moving opening brace to same line #1069

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
MRWeather opened this issue Oct 25, 2017 · 2 comments

Comments

@MRWeather
Copy link

PS v1.0> (Get-CimInstance Win32_OperatingSystem).version
10.0.15063

PS v1.0> code -v
1.17.2
b813d12980308015bcd2b3a2f6efa5c810c33ba5
PS v1.0> $pseditor.EditorServicesVersion
PS v1.0> code --list-extensions --show-versions
donjayamanne.python@0.7.0
ms-mssql.mssql@1.2.0
ms-vscode.PowerShell@1.4.3
ms-vsts.team@1.122.0
PS v1.0> $PSVersionTable

Name Value


PSVersion 5.1.15063.608
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.608
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Any variation of code formatting that moves the opening brace to the same line should check for an end-of-line comment:

before formatting

foreach ($s in $y ) # loop through $y
{
Write-Host $s
}

after formatting, the opening brace becomes part of the comment

foreach ($s in $y ) # loop through $y {
Write-Host $s
}
I don't code comments that way, but I have run into it several times when formatting other's code.

@daviwil
Copy link
Contributor

daviwil commented Oct 25, 2017

Ouch! That's definitely wrong. I'll move this issue over to the PSScriptAnalyzer repo.

@daviwil
Copy link
Contributor

daviwil commented Oct 25, 2017

This issue was moved to PowerShell/PSScriptAnalyzer#826

@daviwil daviwil closed this as completed Oct 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants