GeezerVison is showing github.com — [Formatter] Indent Right(hand side) `CommandExpressionAst` · Issue #2175 · PowerShell/PSScriptAnalyzer
[Formatter] Indent Right(hand side) CommandExpressionAst #2175DescriptionIndent (a multiline) righthand side (list) expression assignment.
Meaning, for a (multiline) Statements.Right CommandExpressionAst (as apposed to Ast's that have already their own embedded indention, as e.g. a PipelineAst), I would like the righthand side to (optionally?) increase the indent:
Wrong way (?)
$List =
'One',
'Two',
'Three'
Correct way
$List =
'One',
'Two',
'Three'
Wrong way (?)
$4 = # or any lengthy variable name aka dot notation
2 + 2
Correct way
$4 = # or any lengthy variable name aka dot notation
2 + 2Activitychanged the title [-][Formatter] Right(hand side) list indention[/-] [+][Formatter] Indent Right(hand side) `CommandExpressionAst`[/+] on Apr 21, 2026bergmeister commented on Apr 21, 2026 iRon7 commented on Apr 21, 2026 ContributorAuthor More actions
@iRon7 are you using latest 1.25.0 release? Cc @liamjpeters
I think I do:
Get-Command Invoke-Formatter
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Invoke-Formatter 1.25.0 PSScriptAnalyzer
But under VSCode, it is a little confusing as the PowerShell extension appears to still come with 1.24.0.
Besides, I noticed another issue, see: PowerShell/vscode-powershell#5474
Why do you ask? liamjpeters commented on Apr 22, 2026 There's nothing that does this currently that I'm aware of.
It would be hard to do, as most of the formatters (including for indentation) act on the stream of tokens and not the AST.
They know that there's an equals sign, but not that it's part of a wider expression with a beginning and an end line and column. So it might be trivial to say that indentation can optionally start at an equals token, but where does it then end?
I guess you could read the AST up front and keep a list of the starts and ends of expressions you want to affect indentation and check that when during token enumeration. It would be messy though and difficult to get right. iRon7 commented on Apr 22, 2026 ContributorAuthor More actions
formatters (including for indentation) act on the stream of tokens and not the AST.
Thank you for your comment, I wasn't aware of that. bergmeister commented on May 7, 2026
@iRon7 are you using latest 1.25.0 release? Cc @liamjpeters
I think I do:
Get-Command Invoke-Formatter
CommandType Name Version Source
Cmdlet Invoke-Formatter 1.25.0 PSScriptAnalyzer
But under VSCode, it is a little confusing as the PowerShell extension appears to still come with 1.24.0. Besides, I noticed another issue, see: PowerShell/vscode-powershell#5474
Why do you ask?
VS Code PowerShell extension ships with PSSA version and binds to that one.
Therefore until it gets updated, please try repro using Invoke-Formatter (Get-Content -Raw) in a different terminal other than the integrated one of VS-Code extension
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|