Skip to content

Add regression tests for attribute scriptblock indentation ([Attr({ … })]) - #2263

Open
Christoph Bergmeister (bergmeister) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-double-indent-attribute-bodies
Open

Christoph Bergmeister (bergmeister) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-double-indent-attribute-bodies

Conversation

Copilot AI commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

In 1.25.0, PSUseConsistentIndentation double-indents the body of an attribute that opens a scriptblock, such as [ArgumentCompleter({ … })] or [ValidateScript({ … })]. The body gets two levels and the closing })] gets one.

# 1.25.0 output
[ArgumentCompleter({
		Param($commandName, $parameterName)
	})]

# Expected (current main)
[ArgumentCompleter({
	Param($commandName, $parameterName)
})]

Root cause / status

Changes

  • Tests only, no rule changes. Two cases are added to the "When multiple openers appear on the same line" context in Tests/Rules/UseConsistentIndentation.tests.ps1:

    • top-level [ArgumentCompleter({ … })], using the issue's example
    • [ValidateScript({ … })] nested inside a function's param() block

    Both start from double-indented input and check that it is corrected. They fail against 1.25.0, so a regression would be caught.

….. })])

Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix double indent issue for attribute bodies in scripting Add regression tests for attribute scriptblock indentation ([Attr({ … })]) Oct 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the added attribute scriptblock indentation regression tests.

No open issues 🎉

What changed in this PR

Adds regression coverage for attribute scriptblock indentation reported in #2216, protecting the existing fix from #2173 without changing rule behavior.

Changes:

  • Tests correction of double-indented bodies and closing delimiters in top-level [ArgumentCompleter({ … })].
  • Tests the same correction for [ValidateScript({ … })] nested inside a function’s param() block.
File Description
Tests/​Rules/​UseConsistentIndentation.tests.ps1 Adds two attribute scriptblock cases to the multiple-openers indentation tests.

Review effort: Balanced

@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 28, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock ([Attr({ … })])

3 participants