Add PowerShell VSCode style settings #5529

Merged
merged 2 commits into from Nov 28, 2017

Conversation

Projects
None yet
5 participants
Contributor

bergmeister commented Nov 22, 2017

Add the following VS Code settings to have a more consistent PowerShell style already at the PR stage. It is mainly based on the K&R/OTBS style, which basically means braces are on the same line and that else, catch, and other keywords are "cuddled" (e.g. } else {)
Personally I'd prefer rather the Stroustrup style where there is no "cuddling" but I have seen that the K&R/OTBS is used more often in the codebase.

  // Sets the codeformatting options to follow the given indent style in a way that is compatible with PowerShell syntax. For more information about the brace styles please refer to https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/81.
  "powershell.codeFormatting.preset": "OTBS",
  
  // Adds a space between a keyword and its associated scriptblock expression.
  "powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
  
  // Adds a space between a keyword (if, elseif, while, switch, etc) and its associated conditional expression.
  "powershell.codeFormatting.whitespaceBeforeOpenParen": true,
  
  // Adds spaces before and after an operator ('=', '+', '-', etc.).
  "powershell.codeFormatting.whitespaceAroundOperator": true,
  
  // Adds a space after a separator (',' and ';').
  "powershell.codeFormatting.whitespaceAfterSeparator": true

bergmeister added some commits Nov 22, 2017

Contributor

rkeithhill commented Nov 23, 2017

When I last touched that file I considered adding these settings but I noticed that the PowerShell script in this repo is not terribly consistent style-wise. I like the idea of it being more consistent but this PR would make it easier for folks using VSCode to mix semantic changes with style changes.

I wonder if it would be better to just take the "styling" hit once and make all the script files conform to this style setup?

Contributor

bergmeister commented Nov 23, 2017

One could apply the styling to the files since VSCode has the Ctrl+K+F shortcut for that. But this is certainly a decision and probably action that the PowerShell team has to make.

@SteveL-MSFT SteveL-MSFT requested a review from daxian-dbw Nov 27, 2017

Owner

SteveL-MSFT commented Nov 27, 2017

I'm fine with the proposed setting changes. We can apply the style universally after GA.

@daxian-dbw daxian-dbw merged commit f5b9942 into PowerShell:master Nov 28, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla All CLA requirements met.
Details

@TravisEz13 TravisEz13 added this to the 6.0.0-GA milestone Nov 29, 2017

TravisEz13 added a commit to TravisEz13/PowerShell that referenced this pull request Nov 29, 2017

@TravisEz13 TravisEz13 referenced this pull request Nov 29, 2017

Merged

Merge 6.0.0 ga changes #5573

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment