From cdff50c6b40ddedf496a415152d2fa21f2e5a76e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:52:49 +0000 Subject: [PATCH 1/3] Initial plan From 219abbd3f4d5f7ce61f19948b72b966d648bf305 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:57:09 +0000 Subject: [PATCH 2/3] Fix comment indentation after skipped pipelines Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com> --- Rules/UseConsistentIndentation.cs | 17 ++++++++++++++--- Tests/Rules/UseConsistentIndentation.tests.ps1 | 12 ++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Rules/UseConsistentIndentation.cs b/Rules/UseConsistentIndentation.cs index 5fd573cc5..0e6680e63 100644 --- a/Rules/UseConsistentIndentation.cs +++ b/Rules/UseConsistentIndentation.cs @@ -282,7 +282,8 @@ public override IEnumerable AnalyzeScript(Ast ast, string file GetCommentRunIndentationOffset( tokens, tokenIndex - 2, - out bool commentRunStartsAfterLineContinuation); + out bool commentRunStartsAfterLineContinuation, + out _); if (commentRunStartsAfterLineContinuation) { tempIndentationLevel++; @@ -302,7 +303,14 @@ public override IEnumerable AnalyzeScript(Ast ast, string file commentIndentationOffset = GetCommentRunIndentationOffset( tokens, tokenIndex, - out bool commentRunStartsAfterLineContinuation); + out bool commentRunStartsAfterLineContinuation, + out bool commentRunStartsAfterPipeline); + if (pipelineIndentationStyle == PipelineIndentationStyle.None && + commentRunStartsAfterPipeline) + { + onNewLine = false; + continue; + } tempIndentationLevel = indentationLevel + (commentRunStartsAfterLineContinuation ? 1 : 0); } @@ -348,7 +356,8 @@ public override IEnumerable AnalyzeScript(Ast ast, string file private static int GetCommentRunIndentationOffset( Token[] tokens, int tokenIndex, - out bool commentRunStartsAfterLineContinuation) + out bool commentRunStartsAfterLineContinuation, + out bool commentRunStartsAfterPipeline) { int firstCommentIndex = tokenIndex; int currentLine = tokens[tokenIndex].Extent.StartLineNumber; @@ -376,6 +385,8 @@ private static int GetCommentRunIndentationOffset( commentRunStartsAfterLineContinuation = firstCommentIndex > 0 && tokens[firstCommentIndex - 1].Kind == TokenKind.LineContinuation; + commentRunStartsAfterPipeline = + PreviousLineEndedWithPipe(tokens, firstCommentIndex, tokens[firstCommentIndex]); int leastIndentedColumn = tokens[firstCommentIndex].Extent.StartColumnNumber; for (int nextCommentIndex = firstCommentIndex + 2; nextCommentIndex < tokens.Length && diff --git a/Tests/Rules/UseConsistentIndentation.tests.ps1 b/Tests/Rules/UseConsistentIndentation.tests.ps1 index 6febc02c7..bf3d4d1fc 100644 --- a/Tests/Rules/UseConsistentIndentation.tests.ps1 +++ b/Tests/Rules/UseConsistentIndentation.tests.ps1 @@ -661,6 +661,18 @@ foo | Test-CorrectionExtentFromContent @params } + It "Should preserve indentation in a comment run after a pipeline with PipelineIndentation None" { + $def = @' +foo | + # first comment + # second comment +'@ + $settings.Rules.PSUseConsistentIndentation.PipelineIndentation = 'None' + $violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings + $violations | Should -BeNullOrEmpty + Invoke-Formatter -ScriptDefinition $def -Settings $settings | Should -Be $def + } + It "Should indent properly after line continuation (backtick) character with pipeline" { $def = @' foo | From 37db3c1047f2cbcf49a34be84bdca087e8206b0f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Mon, 26 Oct 2026 21:30:47 +0000 Subject: [PATCH 3/3] Fix inconsistent indentation in UseConsistentIndentation tests Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- Tests/Rules/UseConsistentIndentation.tests.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/Rules/UseConsistentIndentation.tests.ps1 b/Tests/Rules/UseConsistentIndentation.tests.ps1 index bf3d4d1fc..d07a7b0a5 100644 --- a/Tests/Rules/UseConsistentIndentation.tests.ps1 +++ b/Tests/Rules/UseConsistentIndentation.tests.ps1 @@ -666,6 +666,7 @@ foo | foo | # first comment # second comment +bar '@ $settings.Rules.PSUseConsistentIndentation.PipelineIndentation = 'None' $violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings