-
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: Identation missing if command was broken over multiple lines #1406
Comments
Thanks for raising it and the level of detail. Very interesting and important. Next week is busy for me, but it's definitely on my tracker to investigate more. In the meantime I verified that the behaviour repros in master as well. |
A more simplified repro is this: foo | bar |
baz The problem goes away if I the first line was just |
First investigations show that due to having 2 pipelines in the first line, the following expression prevents an increase of the expected pipeline indentation for the rule setting
bool isFirstPipeInPipeline = pipelineAsts.Any(pipelineAst => PositionIsEqual(((PipelineAst)pipelineAst).PipelineElements[0].Extent.EndScriptPosition, tokens[tokenIndex - 1].Extent.EndScriptPosition)); This condition was added in PR #1318 as a fix for a different but similar multi-line bug. I think if we can improve this conditional logic then this bug should be resolvable without side effects. The improvement would be to not only check if the pipe is the first pipe in a Pipeline we need to check if but in addition also if there are multiple pipes on the same line that the pipe in question is the last of those. |
Before submitting a bug report:
Steps to reproduce
Format this file: https://github.com/pcgeek86/PSGitHub/blob/5fa152568f3218843bbec97c5604d6b16b03066f/Functions/Public/New-GitHubPullRequest.ps1#L183
with
Expected behavior
Should stay the same
Actual behavior
Output (indendation wrong after the pipe):
If an unexpected error was thrown then please report the full error details using e.g.
$error[0] | Select-Object *
Environment data
The text was updated successfully, but these errors were encountered: