PowerShell / PowerShell/vscode-powershell

formatting should allow brace indent to match contained code indent

Open
#462 11 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Code Formatting Issue-Enhancement
Dominant language
TypeScript
Stars
1.9k
Forks
547
PR merge metrics
No merged PRs in 30d

Description

System Details
  • Operating system name and version: win7x64
  • VS Code version: 1.8.2
  • PowerShell extension version: 0.9.0
  • Output from $PSVersionTable:
Name                           Value                                           
----                           -----                                           
PSVersion                      5.1.14409.1005                                  
PSEdition                      Desktop                                         
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                         
BuildVersion                   10.0.14409.1005                                 
CLRVersion                     4.0.30319.42000                                 
WSManStackVersion              3.0                                             
PSRemotingProtocolVersion      2.3                                             
SerializationVersion           1.1.0.1   
Issue Description

howdy y'all,

currently the code formatter indents the braces & sub-controls [elseif/else] to the same level as the control block. i want them indented to the same level as the code.

default ...

if ($TestBool -eq $True)    
{    
    Write-Output '$TestBool is TRUE.'    
}    
elseif ($TestBool -eq $False)    
{    
    Write-Output '$TestBool is FALSE.'    
}    
else    
{    
    Write-Output '$TestBool appears to be non-boolean.'    
}    

what i would prefer ...

if ($TestBool -eq $True)
    {
    Write-Output '$TestBool is TRUE.'
    }
    elseif ($TestBool -eq $False)
    {
    Write-Output '$TestBool is FALSE.'
    }
    else
    {
    Write-Output '$TestBool appears to be non-boolean.'
    }

yes, it fails to match your documented style. [sigh ...] however,it is far easier for me to read than the style you chose.

i would dearly like to be able to set that indent style. it's whitesmith, i believe.

take care,
lee

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue concerns the PowerShell formatter in the VS Code extension but names no files, tests, or entry points. Start by locating the formatter and its existing formatting settings; done means users can select an indentation style that places braces and else/elseif at the contained-code indent, including the requested Whitesmith style.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, typescript, vscode
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.