PowerShell / PowerShell/PowerShellEditorServices

Functions (and other logic) within Regions should be indented

Open
#2,034 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Code Formatting Issue-Enhancement
Dominant language
C#
Stars
767
Forks
266
Avg merge
3d 16h
Merged PRs (30d)
1

Description

Summary of the new feature / enhancement

Indentation should incoprorate Regions, if they exist. This logic is akin to why the contents of functions is indented.
Note: I have searched and found no support for this, and Found no better place to request this enhancement. I am using Visual Studio Code with the MS PowerShell Plugin. Language specific Editor settings do not support doing this: https://code.visualstudio.com/docs/getstarted/settings#_language-specific-editor-settings
___ is used instead of spaces because the View of the issue removed spaces
Preferred:

================

Expanded:


Region Main
___Function Main {
______ValidateSettings
Collapsed:


Region Main
___Function Main {
___}
___Function Function1 {
___}
___Function Function2 {
___}
Current:

Expanded:

Region Main
Function Main {
_____ValidateSettings
Collapsed:


Region Main

Function Main {

_____ValidateSettings
}
Function Function1 {
}
Function Function2 {
}

Proposed technical implementation details (optional)

The Default Auto-Formatting should indent Functions when they exist within Regions.
Not preferred, as this is user by user: provide language-specific-editor-settings to enable this

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the default auto-formatting implementation used by the PowerShell language service and compare it with the issue's expanded and collapsed Region examples. Check how function contents are currently indented, then determine how the requested Region nesting should be represented and validate the behavior through the formatter's existing test or verification path, if one is present.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.