Skip to content

Commit 7d8d841

Browse files
Copilotbergmeister
andauthored
Fix pipeline context for inline comments
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
1 parent 2e1c903 commit 7d8d841

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎Rules/UseConsistentIndentation.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,10 @@ private static bool PipelineIsFollowedByNewlineOrLineContinuation(Token[] tokens
606606

607607
private static bool PreviousLineEndedWithPipe(Token[] tokens, int tokenIndex, Token token)
608608
{
609-
if (tokenIndex < 2 || token.Extent.StartLineNumber == 1)
609+
if (tokenIndex < 2 ||
610+
(tokens[tokenIndex - 1].Kind != TokenKind.NewLine &&
611+
tokens[tokenIndex - 1].Kind != TokenKind.LineContinuation) ||
612+
token.Extent.StartLineNumber == 1)
610613
{
611614
return false;
612615
}

‎Tests/Rules/UseConsistentIndentation.tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ Write-Output |
323323
<# first #> <# second #>
324324
<# note #> -InputObject 'value'
325325
'@
326-
$settings.Rules.PSUseConsistentIndentation.PipelineIndentation = 'NoIndentation'
326+
$settings.Rules.PSUseConsistentIndentation.PipelineIndentation = 'None'
327327

328328
Invoke-Formatter -ScriptDefinition $scriptDefinition -Settings $settings |
329329
Should -Be $scriptDefinition

0 commit comments

Comments
 (0)