vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

Code formatting preset - Add ability to override settings set by preset

Open o-l-a-v opened this issue 1 year ago • 2 comments

Prerequisites

  • [X] I have written a descriptive issue title.
  • [X] I have searched all issues to ensure it has not already been reported.

Summary

A lot of people including me like OTBS with else on a new line.

To achieve this with vscode-powershell one have to use "powershell.codeFormatting.preset": "Custom" and set all formatting rules one by one.

It'd be nice with the ability to override any setting set by a preset. If this is not possible or feasible maybe a new preset can be added to PSScriptAnalyzer:

Proposed Design

No response

o-l-a-v avatar Dec 01 '24 12:12 o-l-a-v

Ah I see what you mean, I'll mark this as Up For Grabs. I'd take a PR if it can do this reasonably suscinctly.

andyleejordan avatar Dec 03 '24 20:12 andyleejordan

These "presets" are a PSES concept and not a scriptanalyzer concept. They are defined here: https://github.com/PowerShell/PowerShellEditorServices/blob/42d13997e346de4601a08b7ab04a5207656ae1dd/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs#L218-L247

So a PR could be fairly straightforward to just add a new entry to the enum with the appropriate settings. Changing the switch to an exhausive pattern matching would also help catch any net-new issues.

JustinGrote avatar Dec 03 '24 22:12 JustinGrote