Skip to content

Commit 9c61aa4

Browse files
author
Kapil Borle
committed
Add option to add new line after open brace
1 parent 9f82b56 commit 9c61aa4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@
276276
"default": true,
277277
"description": "Places open brace on the same line as its associated statement."
278278
},
279+
"powershell.codeformatting.newLineAfterOpenBrace":{
280+
"type":"boolean",
281+
"default": true,
282+
"description": "A new line must follow an open brace."
283+
},
279284
"powershell.codeformatting.indentationSize":{
280285
"type":"number",
281286
"default": 4,

src/features/DocumentFormatter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ class PSDocumentFormattingEditProvider implements vscode.DocumentFormattingEditP
139139
let ruleProperty: string;
140140
switch (rule) {
141141
case "PSPlaceOpenBrace":
142-
// TODO Add newlineafter option to settings
143142
ruleProperty = `${rule} = @{
144143
Enable = \$true
145144
OnSameLine = \$${settings.codeformatting.openBraceOnSameLine}
146-
NewLineAfter = \$true
145+
NewLineAfter = \$${settings.codeformatting.newLineAfterOpenBrace}
147146
}`;
148147
break;
149148

src/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import vscode = require('vscode');
88

99
export interface ICodeFormattingSettings {
1010
openBraceOnSameLine: boolean;
11+
newLineAfterOpenBrace: boolean;
1112
indentationSize: number;
1213
}
1314

@@ -48,6 +49,7 @@ export function load(myPluginId: string): ISettings {
4849

4950
let defaultCodeFormattingSettings: ICodeFormattingSettings = {
5051
openBraceOnSameLine: true,
52+
newLineAfterOpenBrace: true,
5153
indentationSize: 4
5254
};
5355

0 commit comments

Comments
 (0)