$PSVersionTable:Name Value
---- -----
PSVersion 5.1.15063.1155
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.1155
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:
PS C:\> code -v
1.25.1
1dfc5e557209371715f655691b1235b6b26a06be
x64
PS C:\> $pseditor.EditorServicesVersion
Major Minor Build Revision
----- ----- ----- --------
1 8 2 0
PS C:\> code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
ApplicationInsights:Sender [ { Error: self signed certificate in certificate chain
at TLSSocket.<anonymous> (_tls_wrap.js:1088:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:188:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38) code: 'SELF_SIGNED_CERT_IN_CHAIN' } ]
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.15063.1155
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.1155
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I am using PowerShell.
I have lines of code link this which are key value pairs
After running Right click -> Format document, it replaces the tabs with spaces for the white spaces between the key and the "=" sign
My settings:
{
"editor.insertSpaces": false,
"editor.tabSize": 4,
"files.encoding": "utf8",
"files.eol": "\r\n",
}
Example
"key" = "test"
changes to
"key" = "test"
Does this issue occur when all extensions are disabled?: No, because there isnt an option to Format document when --disable-extension used.
Hi @Midacts, can you execute the following command to see if you get the same result:
> Invoke-Formatter (Get-Content -Raw ./path/to/your/script.ps1) > output.ps1
If output.ps1 here also has the converted tabs/spaces, then the problem is occurring in PSScriptAnalyzer's Invoke-Formatter command. Otherwise, it is likely a problem in EditorServices.
Running the above command turned all tabs into spaces and saved the file as UTF-16 LE.
I did notice, in examples like PSCustomObjects, it didnt replaces all spaces with tabs, maybe 1+ of the tabs stayed a tab and all the rest were changed to spaces.
What would next steps be?
Thanks for the great lead.
Running Invoke-Formatter with '-Verbose' shows that it is using a 'SettingsCodeFormatting.psd1' file in the PSScriptAnalyzer module.
I made my own codeformatting.psd1 file and it did use tabs EXCEPT in the case of key/value pairs. It converted to spaces between the key and the equal sign.
Thanks for doing that! I'll close this now since it's a Script Analyzer issue. Let me know if you feel otherwise! 馃憤
Most helpful comment
Thanks for the great lead.
Running
Invoke-Formatterwith '-Verbose' shows that it is using a 'SettingsCodeFormatting.psd1' file in the PSScriptAnalyzer module.I made my own codeformatting.psd1 file and it did use tabs EXCEPT in the case of key/value pairs. It converted to spaces between the key and the equal sign.
PSScriptAnalyzer issue opened