-
Notifications
You must be signed in to change notification settings - Fork 395
Formatter fails for multi-line pipelines when the first line has two or more pipes #1459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@EklipZgit Thanks for the detailed report. Some fixes and improvements have been made after the release of the current version 1.18.3. With the current state of master the formatted output doesn't have the wrong indentation of the second last brace any more shown in your output but it is still missing the expected, additional indentation in the last 2 examples: if ($true)
{
foreach ($i in 0..10)
{
$works = $something.Value |
Group-Object -NoElement |
Where-Object { $_.Count -gt 2 } |
Sort-Object -Property Count -Descending |
Select-Object -First 1 -ExpandProperty Name
$andThisWorks = $something.Value |
Group-Object -NoElement | Where-Object { $_.Count -gt 1 } | # doubled pipeline on non-first line
Sort-Object -Property Count -Descending |
Select-Object -First 1 -ExpandProperty Name
$broken = $something.Value | Group-Object -NoElement | # doubled pipeline on first line
Where-Object { $_.Count -gt 1 } |
Sort-Object -Property Count -Descending |
Select-Object -First 1 -ExpandProperty Name
$norDoesTripleWork = $something.Value | Group-Object -NoElement | Where-Object { $_.Count -gt 1 } | # tripled pipeline on non-first line
Sort-Object -Property Count -Descending |
Select-Object -First 1 -ExpandProperty Name
}
} Formatting with the if ($true)
{
foreach ($i in 0..10)
{
$works = $something.Value |
Group-Object -NoElement |
Where-Object { $_.Count -gt 2 } |
Sort-Object -Property Count -Descending |
Select-Object -First 1 -ExpandProperty Name
$andThisWorks = $something.Value |
Group-Object -NoElement | Where-Object { $_.Count -gt 1 } | # doubled pipeline on non-first line
Sort-Object -Property Count -Descending |
Select-Object -First 1 -ExpandProperty Name
$broken = $something.Value | Group-Object -NoElement | # doubled pipeline on first line
Where-Object { $_.Count -gt 1 } |
Sort-Object -Property Count -Descending |
Select-Object -First 1 -ExpandProperty Name
$norDoesTripleWork = $something.Value | Group-Object -NoElement | Where-Object { $_.Count -gt 1 } | # tripled pipeline on non-first line
Sort-Object -Property Count -Descending |
Select-Object -First 1 -ExpandProperty Name
}
} The reason why the default setting of |
@EklipZgit Some investigation shows that if the trailing comment in the last examples gets removed, then the formatter indents correctly. Therefore the only case we have to fix is: foo | # comment
bar I opened a PR for it to fix that (see link below) |
@bergmeister I dunno if this is the place for this discussion, but for what it's worth I would expect the default behavior to not touch these, quite honestly. I have always double indented mine as a LINQ indentation style i brought with me from C#, and I find it troubling that not only is the double-indent not an option (fine, I'm not standard, can't really complain about that), but none of the options will just leave it alone. Personally, leave-it-alone should be the default behavior imo for personal-preference style stuff like this. If we bothered multi-lining a pipeline then it probably already looks the way we want it to look ;) Absolute worst case is automatically de-indenting everybodies nicely indented pipeline continuations like it does now though, so I would definitely settle with IncreaseIndentationForFirstPipeline if "don't auto format multi-line pipelines" isn't an acceptable default. |
@EklipZgit Yes, the plan is to have |
Issue Description
Under extension settings, set Pipeline Indentation Style to IncreaseIndentationForFirstPipeline (which I think is a more sensible default than No Indentation though I don't know what the official community guidelines say on the topic...).
Then format the following:
Output is
Attached Logs
Follow the instructions in the README about
capturing and sending logs.
Environment Information
Visual Studio Code
PowerShell Information
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
The text was updated successfully, but these errors were encountered: