Repository navigation
[Formatter] Indent Right(hand side) CommandExpressionAst #2175
Description
Activity
- changed the title
[-][Formatter] Right(hand side) list indention[/-][+][Formatter] Indent Right(hand side) `CommandExpressionAst`[/+]on Apr 21, 2026 bergmeister commented
on Apr 21, 2026 CollaboratorMore actionsiRon7 are you using latest 1.25.0 release? Cc Liam Peters (@liamjpeters)
@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#5474Why do you ask?
liamjpeters commented
on Apr 22, 2026 ContributorMore actionsThere'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.
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 CollaboratorMore 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 with1.24.0. Besides, I noticed another issue, see: PowerShell/vscode-powershell#5474Why 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
Indent (a multiline) righthand side (list) expression assignment.
Meaning, for a (multiline)
Statements.RightCommandExpressionAst(as apposed toAst's that have already their own embedded indention, as e.g. aPipelineAst), I would like the righthand side to (optionally?) increase the indent:Wrong way (?)
Correct way
Wrong way (?)
Correct way