From 128cac4f45777b108c8815605582c1cd75a1c54c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Oct 2026 22:29:20 +0000 Subject: [PATCH 1/2] Initial plan From 841dc4ceb5e55cd8ffff722cd9b47ae07fef86d4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Oct 2026 22:32:17 +0000 Subject: [PATCH 2/2] Add regression tests for attribute scriptblock indentation ([Attr({ ... })]) Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com> --- .../Rules/UseConsistentIndentation.tests.ps1 | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Tests/Rules/UseConsistentIndentation.tests.ps1 b/Tests/Rules/UseConsistentIndentation.tests.ps1 index 6bf241116..61ea5e03b 100644 --- a/Tests/Rules/UseConsistentIndentation.tests.ps1 +++ b/Tests/Rules/UseConsistentIndentation.tests.ps1 @@ -1027,6 +1027,48 @@ $( '@ Invoke-Formatter -ScriptDefinition $idempotentScriptDefinition -Settings $settings | Should -Be $idempotentScriptDefinition } + + It "Should not double-indent attribute that opens a scriptblock: [ArgumentCompleter({" { + $def = @' +[ArgumentCompleter({ + Param($commandName, $parameterName) + $validKeys = @('a', 'b') + $validKeys | Where-Object { $_ } | ForEach-Object { "$_=" } + })] +'@ + $expected = @' +[ArgumentCompleter({ + Param($commandName, $parameterName) + $validKeys = @('a', 'b') + $validKeys | Where-Object { $_ } | ForEach-Object { "$_=" } +})] +'@ + Invoke-Formatter -ScriptDefinition $def -Settings $settings | Should -Be $expected + } + + It "Should not double-indent attribute that opens a scriptblock inside a param block: [ValidateScript({" { + $def = @' +function Test-Function { + param( + [ValidateScript({ + $_ -gt 0 + })] + $Value + ) +} +'@ + $expected = @' +function Test-Function { + param( + [ValidateScript({ + $_ -gt 0 + })] + $Value + ) +} +'@ + Invoke-Formatter -ScriptDefinition $def -Settings $settings | Should -Be $expected + } } Context "When tabs instead of spaces are used for indentation" {