PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.72k stars 493 forks source link

The extension insists on adding the addWhitespaceAroundPipe setting to my workspace settings file #2842

Closed rkeithhill closed 4 years ago

rkeithhill commented 4 years ago

System Details

System Details Output

### VSCode version: 1.47.3 91899dcef7b8110878ea59626991a18c8a6a1b3e x64

### VSCode extensions:
abusaidm.html-snippets@0.2.1
atlassian.atlascode@2.6.6
bierner.emojisense@0.7.0
bierner.github-markdown-preview@0.0.2
bierner.markdown-checkbox@0.1.3
bierner.markdown-emoji@0.0.9
bierner.markdown-preview-github-styles@0.1.6
bierner.markdown-yaml-preamble@0.0.4
DavidAnson.vscode-markdownlint@0.36.2
DotJoshJohnson.xml@2.5.1
eamodio.gitlens@10.2.2
EditorConfig.EditorConfig@0.15.1
eg2.tslint@1.0.44
johnpapa.winteriscoming@1.4.3
Mikael.Angular-BeastCode@8.1.2
ms-dotnettools.csharp@1.22.1
ms-edgedevtools.vscode-edge-devtools@1.0.8
ms-python.python@2020.7.96456
ms-vscode-remote.remote-containers@0.128.0
ms-vscode-remote.remote-ssh@0.51.0
ms-vscode-remote.remote-ssh-edit@0.51.0
ms-vscode-remote.remote-ssh-explorer@0.51.0
ms-vscode-remote.remote-wsl@0.44.4
ms-vscode-remote.vscode-remote-extensionpack@0.20.0
ms-vscode.cpptools@0.29.0
ms-vscode.powershell-preview@2020.7.0
ms-vscode.vscode-typescript-tslint-plugin@1.2.3
msjsdiag.debugger-for-chrome@4.12.9
msjsdiag.debugger-for-edge@1.0.15
redhat.vscode-yaml@0.9.1
robinbentley.sass-indented@1.5.1
sibiraj-s.vscode-scss-formatter@2.0.1
SimonSiefke.svg-preview@2.8.3
spmeesseman.vscode-taskexplorer@1.26.3
twxs.cmake@0.0.17
vsls-contrib.codetour@0.0.34
vsls-contrib.gistfs@0.1.8
vsls-contrib.gitdoc@0.0.6
wayou.vscode-todo-highlight@1.0.4
yzhang.markdown-all-in-one@3.2.0

### PSES version: 2.3.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.1.0-preview.5
PSEdition                      Core
GitCommitId                    7.1.0-preview.5
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

I've had other extensions do this and it is very annoying because it creates unnecessary Git diffs / files committed. Basically when I open a PS1 file in my repo, this change gets made to the workspace's settings.json file:

image

Expected Behaviour

The extensions should never automatically modify my workspace's settings.json file.

Actual Behaviour

The settings.json is being modified behind my back. vscode-powershell.zip

Attached Logs

Follow the instructions in the troubleshooting docs about capturing and sending logs.

rjmholt commented 4 years ago

Looks like the test for the deprecated setting isn't specific enough and needs to be modified

rjmholt commented 4 years ago

Here's the relevant change: https://github.com/PowerShell/vscode-powershell/pull/2830

TylerLeonhardt commented 4 years ago

cc @bergmeister

bergmeister commented 4 years ago

@rkeithhill Have you got the whitespaceAroundPipe setting defined somewhere (user or workspace scope?). Because the code is there to move the setting from the deprecated no-op whitespaceAroundPipe setting to the new addWhitespaceAroundPipe.

rkeithhill commented 4 years ago

It's not in my user settings. Here are all the user settings I have defined for PowerShell:

    "powershell.codeFolding.showLastLine": false,
    "powershell.codeFormatting.preset": "Stroustrup",
    "powershell.debugging.createTemporaryIntegratedConsole": false,
    "powershell.developer.editorServicesLogLevel": "Diagnostic",
    "powershell.developer.editorServicesWaitForDebugger": false,
    "powershell.enableProfileLoading": true,
    "powershell.integratedConsole.focusConsoleOnExecute": true,
    "powershell.integratedConsole.showOnStartup": true,
    "powershell.powerShellDefaultVersion": "PowerShell Preview (x64)",
    "powershell.scriptAnalysis.enable": true,
    "powershell.sideBar.CommandExplorerVisibility": false,
    "powershell.useX86Host": false,

There are no PowerShell settings in the workspace settings: image

PrzemyslawKlys commented 4 years ago

I have same problem:

image

It keeps on adding it.

image

If i delete the file

image

But later on extension will again "fix it".

image

ili101 commented 4 years ago

Same here +1

JustinGrote commented 4 years ago

For me its also injecting into my workspace settings, not just user settings.

TylerLeonhardt commented 4 years ago

Looks like no matter what, configuration.has(deprecatedSetting) is true. https://github.com/PowerShell/vscode-powershell/blob/68a8e152afc72b81073c6341ef04b6508dfdcc24/src/session.ts#L335-L335

TylerLeonhardt commented 4 years ago

I've got a fix out for this.

bergmeister commented 4 years ago

Sorry, I was quite busy the last days, thanks for fixing it. When I was testing it, the debug instance of VS-Code did not have a workspace open with .vscode folder, hence why I did not notice this when testing. I am surprised this is coming up only now since the migration of the old setting to the new setting has been in the preview for a few months now, the last preview only tweaked the behaviour to additionally remove the old setting.

TylerLeonhardt commented 4 years ago

No worries!

AArnott commented 4 years ago

I'm still seeing this behavior. What version of the extension has the fix?

Apparently I have two potentially relevant extensions installed: image

JustinGrote commented 4 years ago

@AArnott you need to have either Powershell or Powershell Preview installed, not both. It should actually be warning you not to do this and to uninstall one every startup.

AArnott commented 4 years ago

It should actually be warning you not to do this and to uninstall one every startup.

Hmm... well I never noticed the warning. Till now. I removed the Preview one and restarted. So far, no settings.json change. :)