$PSVersionTable:Name Value
---- -----
PSVersion 5.1.15063.502
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.502
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
code -v:1.15.1
41abd21afdf7424c89319ee7cb0445cc6f376959
$psEditor.EditorServicesVersion:Major Minor Build Revision
----- ----- ----- --------
1 4 1 0
code --list-extensions --show-versions:ms-vscode.PowerShell
PSDocumentFormattingEditProvider.getEditorSettings does not currently consume language-specific editor settings, if defined.
I have fixed this on a local copy of the extension by replacing "editor" with "powershell" in the call to vscode.workspace.getConfiguration, but I am not familiar enough with the language and environment to determine if this is a proper solution.
Full replication steps with description of practical impact are in this (rightfully) closed VSCode issue.
I have this problem also.
In the user settings file I have:
"editor.insertSpaces": false,
Then a powershell configuration override with:
"[powershell]": {
"editor.insertSpaces": true
},
When I select "Format Document" in the context menu, the file is formatted with tabs.
The powershell configuration override setting is ignored.
I don't know if it ties in here, but if you have .editorconfig defined and the VS Code extension for EditorConfig installed you'll see the VS Code editor correctly figures out tab type/size but the formatter here doesn't.
Thanks for the info!
To @NathanielArnoldR2, I think you're almost right with that change from "editor" to "powershell". If you did something like this, we could better handle situation where a user has it set for their editor but not PowerShell AND the situation where a user has it set for PowerShell but not editor:
If we don't get a value for this field in the "powershell" editor config, lets check in "editor" editor config for the value and use that
It should be relatively trivial to implement if you'd like to take a crack at it, @NathanielArnoldR2!
Anyone got quick fix to bypass it temporary, until official fix?
I've just started learning about VS Code extension writing and I think the solution here will be:
sendDocumentFormatRequest the vscode.TextEditor for the document is already retrievedgetEditorSettings is calledgetEditorSettings use textEditor.options.insertSpaces and textEditor.options.tabSize to obey the current editor window's settings instead of getting the global settings directly. This should allow language-specific overrides and EditorConfig stuff to function.I'll see if I can come up with a PR for this.
Submitted a PR. Tested locally, I can get EditorConfig and on-the-fly settings overrides per editor window to take effect. Pretty simple fix.
Closing as the PR has been merged..thanks for the fix @tillig!!
Most helpful comment
I have this problem also.
In the user settings file I have:
"editor.insertSpaces": false,
Then a powershell configuration override with:
"[powershell]": {
"editor.insertSpaces": true
},
When I select "Format Document" in the context menu, the file is formatted with tabs.
The powershell configuration override setting is ignored.