Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@
"type": "boolean",
"default": true,
"description": "There must be a whitespaces after a separator (',' and ';')."
},
"powershell.codeFormatting.ignoreOneLineBlock": {
"type": "boolean",
"default": true,
"description": "Ignore blocks of code on one line. For example, if true, the braces in \"if (...) {...} else {...}\", will not be formatted."
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/features/DocumentFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
case "PSPlaceOpenBrace":
ruleSettings["OnSameLine"] = psSettings.codeFormatting.openBraceOnSameLine;
ruleSettings["NewLineAfter"] = psSettings.codeFormatting.newLineAfterOpenBrace;
ruleSettings["IgnoreOneLineBlock"] = psSettings.codeFormatting.ignoreOneLineBlock;
break;

case "PSPlaceCloseBrace":
ruleSettings["IgnoreOneLineBlock"] = psSettings.codeFormatting.ignoreOneLineBlock;
break;

case "PSUseConsistentIndentation":
Expand Down
4 changes: 3 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface ICodeFormattingSettings {
whitespaceBeforeOpenParen: boolean;
whitespaceAroundOperator: boolean;
whitespaceAfterSeparator: boolean;
ignoreOneLineBlock: boolean;
}

export interface IScriptAnalysisSettings {
Expand Down Expand Up @@ -58,7 +59,8 @@ export function load(myPluginId: string): ISettings {
whitespaceBeforeOpenBrace: true,
whitespaceBeforeOpenParen: true,
whitespaceAroundOperator: true,
whitespaceAfterSeparator: true
whitespaceAfterSeparator: true,
ignoreOneLineBlock: true
};

return {
Expand Down