Vscode-powershell: Language-Specific editor.* Settings Ignored When Formatting Document

Created on 4 Sep 2017  路  7Comments  路  Source: PowerShell/vscode-powershell

System Details

  • Operating system name and version: Windows 10 1703 (15063)
  • VS Code version: 1.15.1
  • PowerShell extension version 1.4.1:
  • Output from $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
  • Output from code -v:
1.15.1
41abd21afdf7424c89319ee7cb0445cc6f376959
  • Output from $psEditor.EditorServicesVersion:
Major  Minor  Build  Revision
-----  -----  -----  --------
1      4      1      0
  • Output from code --list-extensions --show-versions:
ms-vscode.PowerShell

Issue Description

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.

Area-Code Formatting Issue-Bug

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.

All 7 comments

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:

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!!

Was this page helpful?
0 / 5 - 0 ratings