From 4d7ae16671bec9838ef2873fca37a1f989f5999c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Oct 2026 17:51:32 +0000 Subject: [PATCH 1/2] Initial plan From 80e81ecd8fe8b394056000deb3f0f435237caf73 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Oct 2026 17:56:57 +0000 Subject: [PATCH 2/2] Exclude trailing pipe comments from comment runs Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com> --- Rules/UseConsistentIndentation.cs | 5 ++++ .../Rules/UseConsistentIndentation.tests.ps1 | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Rules/UseConsistentIndentation.cs b/Rules/UseConsistentIndentation.cs index 74f3602d6..7fc98509d 100644 --- a/Rules/UseConsistentIndentation.cs +++ b/Rules/UseConsistentIndentation.cs @@ -404,6 +404,11 @@ private static int GetCommentRunIndentationOffset( return 0; } + if (HasCodeBeforeCommentOnSameLine(tokens, tokenIndex)) + { + return 0; + } + int firstCommentIndex = tokenIndex; int currentLine = tokens[tokenIndex].Extent.StartLineNumber; int precedingIndex = tokenIndex - 1; diff --git a/Tests/Rules/UseConsistentIndentation.tests.ps1 b/Tests/Rules/UseConsistentIndentation.tests.ps1 index e178a146d..81c90d324 100644 --- a/Tests/Rules/UseConsistentIndentation.tests.ps1 +++ b/Tests/Rules/UseConsistentIndentation.tests.ps1 @@ -932,6 +932,31 @@ function test { Invoke-Formatter -ScriptDefinition $expected -Settings $settings | Should -Be $expected } + It "Should exclude a trailing comment after a line-leading pipe from comment runs" { + $def = @' +function test { + foo ` + | # trailing +# standalone + bar +} +'@ + $expected = @' +function test { + foo ` + | # trailing + # standalone + bar +} +'@ + $settings.Rules.PSUseConsistentIndentation.PipelineIndentation = 'NoIndentation' + $formatted = Invoke-Formatter -ScriptDefinition $def -Settings $settings + + $formatted | Should -Be $expected + Invoke-Formatter -ScriptDefinition $formatted -Settings $settings | + Should -Be $expected + } + It "Should indent properly after line continuation (backtick) character with pipeline" { $def = @' foo |