-
Notifications
You must be signed in to change notification settings - Fork 382
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
PSUseConsistentIndentation.PipelineIndentation.None
or 3
deletes commandlet name
#1580
Comments
another way this seems to occur (related to my submission #2962), is strings with command substitution are also affected when applying formatting. for example, original code:
becomes
after applying document formatting. request: would it be possible or even be practical to add an option to ignore string contents when applying document formatting? @SydneyhSmith |
@ninmonkey Can you confirm if this is still reproducing with v1.20.0? |
I was able to reproduce this on 1.20.0 with indentation style 'none' |
Seems like something we should prioritize, being destructive as it is. |
It appears to only be breaking when set to Environment
Initial scriptGet-ChildItem |
Where-Object Name -Like 'foo'
Get-ChildItem |
ForEach-Object Name Mode: Get-ChildItem |
Where-Object Name -Like 'foo'
Get-ChildItem |
ForEach-Object Name Mode: Get-ChildItem |
Where-Object Name -Like 'foo'
Get-ChildItem |
ForEach-Object Name Mode: Get-ChildItem |
Where-Object Name -Like 'foo'
Get-ChildItem |
ForEach-Object Name Mode: Get-ChildItem |
Where-Object Name -Like 'foo'
Get-ChildItem |
ForEach-Object Name Mode: Get-ChildItem |
Name -Like 'foo'
Get-ChildItem |
Name Mode: `` Get-ChildItem |
Where-Object Name -Like 'foo'
Get-ChildItem |
ForEach-Object Name |
Does that still occur in 1.20 ? I am not getting that, at least with this config $settings = @{
IncludeRules = @('PSUseConsistentIndentation')
Rules = @{
PSUseConsistentIndentation = @{
Enable = $true
# Kind = 'space'
PipelineIndentation = 'None' # broke
# IndentationSize = 4
}
}
} |
Thanks for the updated repro info, I know there were a few cases with the formatter removing code in 1.19.0 that were fixed in 1.19.1 but it seems there is still one case outstanding (or re-introduced), I will take a look at it this week ✋. At least it's only for a non-default settings and the affected |
I had a first look at it today, I can confirm it's a bug of the
Below is a PR with a fix, it seems the existing test cases were too simple to not catch this scenario. |
When
PSUseConsistentIndentation.PipelineIndentation
is set toNone
or3
it deleteswhere-object
andforeach-object
Steps to reproduce
Sample input:
It happens using the format
foo | bar
These formats work correctly
Test cases
Expected behavior
Results that contain
Foreach-Object
andWhere-Object
Actual behavior
All enum types:
Environment data
Occurs in normal powershell and
vscode-powershell
's integrated terminalThe existing issues like #1168 deal with formatting, not mutating code
The text was updated successfully, but these errors were encountered: