You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Preview-2020-5.0] Formatting broken when using default PipelineIndentationStyle setting value of None #2696
I updated the preview extension in my insider version of code and cannot repro. Przemysław Kłys (@PrzemyslawKlys) Have you tried using the > Format Document command? Because I know some other extensions can override the shortcut for formatting a selection
This actually gets me Invoke-Formatter: Cannot parse settings. Will abort the invocation. So either the settings aren't correct or (more likely) I did it wrong.
Christoph Bergmeister (@bergmeister) sorry I was side-chaining 😅 that was more of a "Chris pls help fix my script to do what I want" than "PSSA is broken"
Przemysław Kłys (@PrzemyslawKlys) Formatting therefore seems to generally work. Please supply the script where the Action hashtable entry does not get corrected. Also: If you revert to the previous extension version and reload, does it still repro? Have you got PSSA 1.19.0 installed locally or do you just use the version that comes out of the box with the extension (both are the same so, no worries)
Yes, I jumped the gun a bit because I just was working on a different file that didn't have hash. Generally last preview didn't have an issue and i have installed 1.19.0 before newest preview so not sure if it's related to PSScriptAnalyzer code, more like some configuration on VsCode part.
Christoph Bergmeister (@bergmeister) I've also noticed something: If you have an older version of PSScriptAnalyzer (1.18.* in my case), this is taking precedence and the assemblies for this are loading in the integrated terminal, rather than the "bundled" vscode one. This prevented for instance parameter casing "format document" from working correctly until I deleted my "modules" version of PSSA and reloading, then it worked fine.
You may want to make sure the module load search order prefers the vscode bundled one.
Przemysław Kłys (@PrzemyslawKlys) try removing your 1.19.0 in your modules folder, I'm saying if you only have the older version still installed, that one takes precedence.
Even in your example, your modules folder one took precedence, I'm saying that the one in the powershell extensions folder bundled with vscode should take precedence even if it is older.
Przemysław Kłys (@PrzemyslawKlys) well ideally it would use an AssemblyLoadContext like the other "builtin" modules so that this is a moot point, but regardless I'd be OK either way as long as it's "whatever the latest version is". Currently it's "Whatever is in Modules takes precedence regardless"
Justin Grote (@JustinGrote) This should not happen, can you open a new issue for that one please? Do you know why that would be TylerLeonhardt
This also happens with the previous version of the preview extension.
Przemysław Kłys (@PrzemyslawKlys) or TylerLeonhardt Can you please rename this issue to something like: [Preview-2020-5.0] Formatting broken when using default PipelineIndentationStyle setting value of None
changed the title [-]Formatting doesn't work on PowerShell Extension Version 2020.5.0[/-][+][Preview-2020-5.0] Formatting broken when using default PipelineIndentationStyle setting value of None[/+]on May 13, 2020
Activity
TylerLeonhardt commentedon May 13, 2020
hmm Christoph Bergmeister (@bergmeister) looks like these are the settings used:
{ "IncludeRules": [ "PSPlaceCloseBrace", "PSPlaceOpenBrace", "PSUseConsistentWhitespace", "PSUseConsistentIndentation", "PSAlignAssignmentStatement" ], "Rules": { "PSUseConsistentIndentation": { "IndentationSize": 4, "Enable": true, "PipelineIndentation": 3, "Kind": "space" }, "PSAvoidUsingCmdletAliases": {}, "PSPlaceOpenBrace": { "Enable": true, "NewLineAfter": true, "OnSameLine": true, "IgnoreOneLineBlock": true }, "PSAlignAssignmentStatement": { "Enable": true, "CheckHashtable": true }, "PSUseCorrectCasing": { "Enable": true }, "PSPlaceCloseBrace": { "Enable": true, "NewLineAfter": false, "IgnoreOneLineBlock": true }, "PSUseConsistentWhitespace": { "CheckPipe": true, "CheckSeparator": true, "CheckOpenBrace": true, "Enable": true, "CheckParameter": false, "CheckOpenParen": true, "CheckPipeForRedundantWhitespace": false, "CheckInnerBrace": true, "CheckOperator": true } } }Does that look alright to you?
bergmeister commentedon May 13, 2020
I updated the preview extension in my insider version of code and cannot repro. Przemysław Kłys (@PrzemyslawKlys) Have you tried using the
> Format Documentcommand? Because I know some other extensions can override the shortcut for formatting a selectionPrzemyslawKlys commentedon May 13, 2020
No change - i tried shorcut, right click format, > format document. I'll uninstall extension and try fresh
PrzemyslawKlys commentedon May 13, 2020
Uninstall/install didn't help
bergmeister commentedon May 13, 2020
I tried switching to PowerShell 5.1 locally to be closer to your environment but it still works... Also tried VS Code stable
bergmeister commentedon May 13, 2020
TylerLeonhardt the settings look to me.
TylerLeonhardt commentedon May 13, 2020
Another option is to run
PSScriptAnalyzerdirectly to see if anything changes:This actually gets me
Invoke-Formatter: Cannot parse settings. Will abort the invocation.So either the settings aren't correct or (more likely) I did it wrong.PrzemyslawKlys commentedon May 13, 2020
Ok, i've it reproduced - only part of formatting doesn't work...
PrzemyslawKlys commentedon May 13, 2020
It doesn't seem to touch things on the left side.. notice the Action on 11th line
bergmeister commentedon May 13, 2020
TylerLeonhardt Running this exact repro script of you, would also throw a settings parser error in 1.18.3, so does not seem to be a regression
TylerLeonhardt commentedon May 13, 2020
Christoph Bergmeister (@bergmeister) sorry I was side-chaining 😅 that was more of a "Chris pls help fix my script to do what I want" than "PSSA is broken"
bergmeister commentedon May 13, 2020
TylerLeonhardt No worries, something is wrong in the format of how you convert the JSON because the following (manually converted) works fine:
bergmeister commentedon May 13, 2020
Przemysław Kłys (@PrzemyslawKlys) Formatting therefore seems to generally work. Please supply the script where the
Actionhashtable entry does not get corrected. Also: If you revert to the previous extension version and reload, does it still repro? Have you got PSSA 1.19.0 installed locally or do you just use the version that comes out of the box with the extension (both are the same so, no worries)PrzemyslawKlys commentedon May 13, 2020
Christoph Bergmeister (@bergmeister)
Yes, I jumped the gun a bit because I just was working on a different file that didn't have hash. Generally last preview didn't have an issue and i have installed 1.19.0 before newest preview so not sure if it's related to PSScriptAnalyzer code, more like some configuration on VsCode part.
Here's the code I am testing it with:
Code above replicates it. On PowerShell (not preview) this is translated to
On preview
18 remaining items
JustinGrote commentedon May 13, 2020
Christoph Bergmeister (@bergmeister) I've also noticed something: If you have an older version of PSScriptAnalyzer (1.18.* in my case), this is taking precedence and the assemblies for this are loading in the integrated terminal, rather than the "bundled" vscode one. This prevented for instance parameter casing "format document" from working correctly until I deleted my "modules" version of PSSA and reloading, then it worked fine.
You may want to make sure the module load search order prefers the vscode bundled one.
This is on a "fresh" load:

PrzemyslawKlys commentedon May 13, 2020
That's weird, I have multiple versions and only new one loads?
JustinGrote commentedon May 13, 2020
Przemysław Kłys (@PrzemyslawKlys) try removing your 1.19.0 in your modules folder, I'm saying if you only have the older version still installed, that one takes precedence.
Even in your example, your modules folder one took precedence, I'm saying that the one in the powershell extensions folder bundled with vscode should take precedence even if it is older.
PrzemyslawKlys commentedon May 13, 2020
Sorry. You're correct.
PrzemyslawKlys commentedon May 13, 2020
I am not sure I agree that it should take precedence tho? Newest one should be used - I often install PSScriptAnalyzer newer than in extension?
JustinGrote commentedon May 13, 2020
Przemysław Kłys (@PrzemyslawKlys) well ideally it would use an AssemblyLoadContext like the other "builtin" modules so that this is a moot point, but regardless I'd be OK either way as long as it's "whatever the latest version is". Currently it's "Whatever is in Modules takes precedence regardless"
bergmeister commentedon May 13, 2020
Justin Grote (@JustinGrote) This should not happen, can you open a new issue for that one please? Do you know why that would be TylerLeonhardt
This also happens with the previous version of the preview extension.
bergmeister commentedon May 13, 2020
Przemysław Kłys (@PrzemyslawKlys) or TylerLeonhardt Can you please rename this issue to something like:
[Preview-2020-5.0] Formatting broken when using default PipelineIndentationStyle setting value of None[-]Formatting doesn't work on PowerShell Extension Version 2020.5.0[/-][+][Preview-2020-5.0] Formatting broken when using default PipelineIndentationStyle setting value of None[/+]PrzemyslawKlys commentedon May 13, 2020
Done