Skip to content
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

Language-Specific editor.* Settings Ignored When Formatting Document #1019

Closed
NathanielArnoldR2 opened this issue Sep 4, 2017 · 7 comments · Fixed by greg-ruminski/scoop-extras#1
Labels

Comments

@NathanielArnoldR2
Copy link

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.

@jimp02
Copy link

jimp02 commented Sep 8, 2017

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.

@tillig
Copy link
Contributor

tillig commented Jun 6, 2018

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.

@TylerLeonhardt
Copy link
Member

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!

@Ash258
Copy link

Ash258 commented Sep 26, 2018

Anyone got quick fix to bypass it temporary, until official fix?

@tillig
Copy link
Contributor

tillig commented Jun 17, 2019

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.

@tillig
Copy link
Contributor

tillig commented Jun 18, 2019

Submitted a PR. Tested locally, I can get EditorConfig and on-the-fly settings overrides per editor window to take effect. Pretty simple fix.

@SydneyhSmith
Copy link
Collaborator

Closing as the PR has been merged..thanks for the fix @tillig!!

greg-ruminski added a commit to greg-ruminski/scoop-extras that referenced this issue Jul 12, 2019
rjmholt pushed a commit to rjmholt/vscode-powershell that referenced this issue Jul 24, 2019
rjmholt added a commit that referenced this issue Jul 26, 2019
* Edit snippets to support $TM_SELECTED_TEXT (#1945)

Edit all-and-only applicable snippets to support $TM_SELECTED_TEXT,
where "applicable" is approximated by whether a snippet contains a
user-specified PowerShell expression, block, or body. Do not add,
remove, or otherwise change any placeholder number or name in order to
preserve backwards-compatibility.

Edit the following snippets (listed by name, not prefix):
- Class
- Constructor
- Method
- Enum
- Cmdlet
- Function-Advanced
- DSC Resource Provider (class-based)
- DSC Resource Provider (function-based)
- comment block
- do-until
- do-while
- while
- for
- for-reversed
- foreach
- function
- Function-Inline
- if
- elseif
- else
- switch
- try-catch
- try-catch-finally
- try-finally
- Workflow
- Workflow ForEachParallel
- Workflow InlineScript
- Workflow Parallel
- Workflow Sequence
- Region Block
- IfShouldProcess
- CalculatedProperty
- PesterDescribeContextIt
- PesterDescribeBlock
- PesterContextIt
- PesterContext
- PesterIt

* Add ArgumentCompleter snippets (#1946)

* Define snippet named 'ArgumentCompleterAttribute with ScriptBlock'

* Define snippet named 'IArgumentCompleter Class'

* Define snippet named 'ArgumentCompleterAttribute ScriptBlock'

* Add #Requires snippets (#1974)

* Add script requirement directive snippets

Adds the following snippets (listed by name, not prefix):
- Requires Assembly
- Requires Assembly Path
- Requires Assembly Version
- Requires Module
- Requires Module RequiredVersion
- Requires Module Version
- Requires PSEdition
- Requires PSSnapin
- Requires PSSnapin Version
- Requires RunAsAdministrator
- Requires ShellId
- Requires Version

* Fix node version detect logic to handle node v10 (#2025)

* #1019: Get format settings from document editor instead of global. (#2035)

* Update PSSA docs Url to point to master branch because master is now the default branch (#2037)

* add machine scope (#2039)

* add machine scope

* use a different setting for test and add user setting test

* remove isExecutable and remove powershell.developer.powerShellExePath

* Add param-block snippet (#2081)
@rjmholt rjmholt removed the Triage label Jul 31, 2019
rasa added a commit to ScoopInstaller/Extras that referenced this issue Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants