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 275
275
"type" :" boolean" ,
276
276
"default" : true ,
277
277
"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."
278
283
}
279
284
}
280
285
}
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ class PSDocumentFormattingEditProvider implements vscode.DocumentFormattingEditP
86
86
// can be undone and redone in a single step
87
87
88
88
// 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 {
90
90
let leftOperand : number = a . correction . edits [ 0 ] . startLineNumber ,
91
91
rightOperand : number = b . correction . edits [ 0 ] . startLineNumber ;
92
92
if ( leftOperand < rightOperand ) {
@@ -136,12 +136,29 @@ class PSDocumentFormattingEditProvider implements vscode.DocumentFormattingEditP
136
136
137
137
getSettings ( rule : string ) : string {
138
138
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
+
139
158
return `@{
140
159
IncludeRules = @('${ rule } ')
141
160
Rules = @{
142
- PSPlaceOpenBrace = @{
143
- OnSameLine = \$${ settings . codeformatting . openBraceOnSameLine }
144
- }
161
+ ${ ruleProperty }
145
162
}
146
163
}` ;
147
164
}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import vscode = require('vscode');
8
8
9
9
export interface ICodeFormattingSettings {
10
10
openBraceOnSameLine : boolean ;
11
+ indentationSize : number ;
11
12
}
12
13
13
14
export interface IScriptAnalysisSettings {
@@ -46,7 +47,8 @@ export function load(myPluginId: string): ISettings {
46
47
} ;
47
48
48
49
let defaultCodeFormattingSettings : ICodeFormattingSettings = {
49
- openBraceOnSameLine : true
50
+ openBraceOnSameLine : true ,
51
+ indentationSize : 4
50
52
} ;
51
53
52
54
return {
You can’t perform that action at this time.
0 commit comments