-
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
Unable to format document in special circumstances #1994
Comments
I've tried a bunch of variations. You can reproduce it with almost any expression that starts with a You can reproduce it with this ($x = 10)
$y = 30 formats as ($x = 10)
$y = 30 contrary, working case 1, ($x = 10) formats correctly 1, ($x = 10) Another fail case ($x = 10), 1
# formats as the same
($x = 10), 1 |
Oh weird, thanks for the report. Did you try it under PSSA directly too? |
No I didn't, sorry. |
The latest version of the extension is using PSSA 1.22, which just came out. It would be helpful to know if this repros directly with |
Thanks so much @PrzemyslawKlys! |
Stepping through Specifically from: PSScriptAnalyzer/Rules/UseConsistentIndentation.cs Lines 165 to 177 in a754b95
The issue seems to be that, if the left paren
AND
THEN that line's indentation is not checked against what we expect it to be. (Other necessary things still happen however) Coming at it for the first time, I find the code-flow of the rule to be difficult to follow. The actual evaluation of whether the indentation is correct happens within the I believe, in the short-term, a change should be made so that in the situation outlined above, we still check the lines indentation is at the level we expect (but we don't increment the indentation level). Longer-term perhaps this rule should be revisited to make it a bit easier to follow and update it's styling slightly. @bergmeister - this looks to be a rule you've put a lot of time and effort into, and you put together the PR that introduced this LParen check (#1469) - What do you think? |
Prerequisites
Summary
Extension works perfectly most of the time in recent months. Today I've noticed weird issue
Where a simple code like this format mostly everything with the exception of lines with Get-Item
Trying to format it, leaves it as is, at the same time it formats everything else around it. So it seems there's something special about it.
PowerShell Version
Visual Studio Code Version
Extension Version
[email protected]
Steps to Reproduce
Visuals
No response
Logs
No response
The text was updated successfully, but these errors were encountered: