Skip to content

Code formatting breaks the code by moving brace to a comment #1272

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
Rogacz opened this issue Apr 16, 2018 · 5 comments
Closed

Code formatting breaks the code by moving brace to a comment #1272

Rogacz opened this issue Apr 16, 2018 · 5 comments

Comments

@Rogacz
Copy link

Rogacz commented Apr 16, 2018

System Details

  • Operating system name and version: Windows 10 1703
  • VS Code version: 1.22.2
  • PowerShell extension version: 1.6.0
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      5.1.15063.966
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.966
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I am experiencing a problem with code formatting.
I used default powershell.codeFormatting settings and have set:

"editor.formatOnPaste": true,
"editor.formatOnType": true,

If I paste a code with opening brace on second line it doesn't check if previous line finished with a comment and moves brace, breaking the code.

c

@wsmelton
Copy link

wsmelton commented Apr 16, 2018

This would be expected to me and not the main reason but one of the reasons why I don't use inline comments.

@Rogacz
Copy link
Author

Rogacz commented Apr 16, 2018

@wsmelton I agree and I don't use inline comments.
But I thought intention of code formatting feature is that I can grab poorly formatted code from internet or co-worker ;) and be able to read it.

@PrzemyslawKlys
Copy link
Contributor

what if you change the formatting to different code formatting preset? PoshCode/PowerShellPracticeAndStyle#81

Seems like Allman could work here?

@TylerLeonhardt
Copy link
Member

This has been fixed in PowerShell/PSScriptAnalyzer#929 . In the next PSScriptAnalyzer version, this will be fixed and the next vscode-extension release after that will contain that fix.

@TylerLeonhardt
Copy link
Member

I'm going to close this for now as external/dupe of PowerShell/PSScriptAnalyzer#826.

If you want to get the CI build of PSSA so that this doesn't happen, go here:
https://ci.appveyor.com/project/PowerShell/psscriptanalyzer/branch/development/job/eeh97eis3ycxn9s9/artifacts

And put the unzipped folder in your $env:PSModulePath

No guarantee that the CI build will be 100% stable 😄

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

4 participants