File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed
Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change 275275 "type" :" boolean" ,
276276 "default" : true ,
277277 "description" : " Places open brace on the same line as its associated statement."
278+ },
279+ "powershell.codeformatting.indentationSize" :{
280+ "type" :" number" ,
281+ "default" : 4 ,
282+ "description" : " The indentation size in number of Space characters."
278283 }
279284 }
280285 }
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ class PSDocumentFormattingEditProvider implements vscode.DocumentFormattingEditP
8686 // can be undone and redone in a single step
8787
8888 // sort in decending order of the edits
89- result . markers . sort ( function ( a : ScriptFileMarker , b : ScriptFileMarker ) : number {
89+ result . markers . sort ( function ( a : ScriptFileMarker , b : ScriptFileMarker ) : number {
9090 let leftOperand : number = a . correction . edits [ 0 ] . startLineNumber ,
9191 rightOperand : number = b . correction . edits [ 0 ] . startLineNumber ;
9292 if ( leftOperand < rightOperand ) {
@@ -136,12 +136,29 @@ class PSDocumentFormattingEditProvider implements vscode.DocumentFormattingEditP
136136
137137 getSettings ( rule : string ) : string {
138138 let settings : Settings . ISettings = Settings . load ( Utils . PowerShellLanguageId ) ;
139+ let ruleProperty : string ;
140+ switch ( rule ) {
141+ case "PSPlaceOpenBrace" :
142+ ruleProperty = `${ rule } = @{
143+ OnSameLine = \$${ settings . codeformatting . openBraceOnSameLine }
144+ }` ;
145+ break ;
146+
147+ case "PSUseConsistentIndentation" :
148+ ruleProperty = `${ rule } = @{
149+ IndentationSize = ${ settings . codeformatting . indentationSize }
150+ }` ;
151+ break ;
152+
153+ default :
154+ ruleProperty = "" ;
155+ break ;
156+ }
157+
139158 return `@{
140159 IncludeRules = @('${ rule } ')
141160 Rules = @{
142- PSPlaceOpenBrace = @{
143- OnSameLine = \$${ settings . codeformatting . openBraceOnSameLine }
144- }
161+ ${ ruleProperty }
145162 }
146163}` ;
147164 }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import vscode = require('vscode');
88
99export interface ICodeFormattingSettings {
1010 openBraceOnSameLine : boolean ;
11+ indentationSize : number ;
1112}
1213
1314export interface IScriptAnalysisSettings {
@@ -46,7 +47,8 @@ export function load(myPluginId: string): ISettings {
4647 } ;
4748
4849 let defaultCodeFormattingSettings : ICodeFormattingSettings = {
49- openBraceOnSameLine : true
50+ openBraceOnSameLine : true ,
51+ indentationSize : 4
5052 } ;
5153
5254 return {
You can’t perform that action at this time.
0 commit comments