Skip to content

Commit be6251d

Browse files
Copilotbergmeister
andauthored
Preserve continuation indentation before block-comment-prefixed arguments (#2247)
* Initial plan * Fix continued comment argument indentation Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
1 parent 075fdbb commit be6251d

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎Rules/UseConsistentIndentation.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,9 @@ private static int GetCommentRunIndentationOffset(
376376
GetCommentRunIndentationOffset(
377377
tokens,
378378
tokenIndex - 2,
379-
out _,
379+
out bool precedingCommentRunStartsAfterLineContinuation,
380380
out commentRunStartsAfterPipeline);
381+
commentRunStartsAfterLineContinuation |= precedingCommentRunStartsAfterLineContinuation;
381382
}
382383

383384
return 0;

‎Tests/Rules/UseConsistentIndentation.tests.ps1‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,18 @@ Write-Output `
268268
Should -Be $scriptDefinition
269269
}
270270

271+
It 'Should preserve continuation indentation before a block-comment-prefixed argument' {
272+
$scriptDefinition = @'
273+
Write-Output `
274+
# comment
275+
<# note #> -InputObject 'value'
276+
'@
277+
$settings.Rules.PSUseConsistentIndentation.PipelineIndentation = 'NoIndentation'
278+
279+
Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings $settings |
280+
Should -Be $scriptDefinition
281+
}
282+
271283
It 'Should preserve indentation when the first comment is not the least-indented with <Kind> indentation' -TestCases @(
272284
@{ Kind = 'space'; Indentation = ' ' }
273285
@{ Kind = 'tab'; Indentation = "`t" }

0 commit comments

Comments
 (0)