PSScriptAnalyzer icon indicating copy to clipboard operation
PSScriptAnalyzer copied to clipboard

Option to indent code in a #region

Open WillyMoselhy opened this issue 3 years ago • 4 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

When writing code, I depend heavily on regions to keep things clean. Sometimes even nested regions. I would love it if we have the option to indent the code in a region to easily find where a region starts and ends.

#region: Hello World!
Write-Host 'Hello World!
#endregion

Should be (optinally)

#region: Hello World!
    Write-Host 'Hello World!
#endregion

Would be even cooler if the indent is adjustable to 1 or 2 spaces instead of 4

Proposed Design

Add option in the formatter to indent regions and specifying by how many spaces.

WillyMoselhy avatar May 12 '22 05:05 WillyMoselhy

Thanks for submitting! I think this needs to be done as a PSScriptAnalyzer rule which will be read as a formatter, you may need to submit there. @bergmeister?

JustinGrote avatar May 12 '22 14:05 JustinGrote

Yes, although regions are not part of the AST and it would need to be a Token based formatting rule, it shouldn't be too bad though so transferring this issue to PSSA repo

bergmeister avatar May 16 '22 16:05 bergmeister

Just wanted to ask if there has been any movement on this?

HurtzDonut avatar Apr 19 '23 14:04 HurtzDonut

If you don't see any linked PRs, then no. We are open to PRs, it's doable.

bergmeister avatar Apr 25 '23 13:04 bergmeister