You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
powershell.codeFormatting.whitespaceBetweenParameters inappropriately removes + operators in string concatenation #1536
When formatting a document with powershell.codeFormatting.whitespaceBetweenParameters enabled, the formatter inappropriately removes + operators in string concatenation.
Steps to reproduce:
Enter this code example: Write-Output ($env:computername + ", " + $env:username) (GitHub is collapsing the whitespace, but there are four spaces on each side of each plus sign)
keyword process is being deleted by whitespaceBetweenParameters
Although this code has a syntax error -- I thought It was still worth noting because:
there are no whitespace/parameters involved
it breaks the language keyword named process. Should that be allowed?
if it's invalid grammar/syntax, shouldn't the formatter complain, instead of applying edits?
the tooltip mentions the alias process. I don't have one default profiles for Powershell 7.0.3 and Windows Powershell 5.1.18
I was curious if the keyword could be aliased:
# does not complainNew-Alias-Name 'process'-Value Get-ChildItem-Verbose -Debug
# this expects more input, it's not using alias
PS>process>>>># Ctrl+C# this isn't eitherprocess .
ParserError:
Line |1|process .
| ~
| Missing statement block after 'process'.
test cases that break
meaning process { } is replaced with Get-Process { }
Activity
rjmholt commentedon Jul 1, 2020
Reproduces with:
in PSSA 1.19.
Transferring to the PSScriptAnalyzer repo
bergmeister commentedon Jul 1, 2020
Rob Holt (@rjmholt) Can you reproduce with the latest master? This issue was probably already fixed in PR #1498
rjmholt commentedon Jul 1, 2020
Looks like I can unfortunately
bergmeister commentedon Jul 20, 2020
Rob Holt (@rjmholt) Are you sure you have pulled all changes in? I can reproduce with 1.19.0 but not with the latest version of
master.rjmholt commentedon Jul 20, 2020
I trust you on this
ninmonkey commentedon Jul 25, 2020
keyword
processis being deleted bywhitespaceBetweenParametersAlthough this code has a syntax error -- I thought It was still worth noting because:
language keywordnamedprocess. Should that be allowed?the tooltip mentions the alias
process. I don't have one default profiles forPowershell 7.0.3andWindows Powershell 5.1.18I was curious if the keyword could be aliased:
test cases that break
meaning
process { }is replaced withGet-Process { }working case
editor services.log
{ "[powershell]": { "editor.formatOnSave": false, "editor.formatOnPaste": false, "editor.autoIndent": "advanced", "editor.formatOnType": true, "files.autoGuessEncoding": false, "files.encoding": "utf8bom" }, "diffEditor.ignoreTrimWhitespace": true, "editor.formatOnPaste": true, "editor.formatOnSave": true, "editor.formatOnType": true, "editor.renderWhitespace": "none", "editor.trimAutoWhitespace": true, "files.trimTrailingWhitespace": true, "powershell editor services.trace.server": "verbose", "powershell.buttons.showPanelMovementButtons": true, "powershell.buttons.showRunButtons": true, "powershell.codeFolding.enable": true, "powershell.codeFolding.showLastLine": true, "powershell.codeFormatting.addWhitespaceAroundPipe": true, "powershell.codeFormatting.autoCorrectAliases": true, "powershell.codeFormatting.ignoreOneLineBlock": true, "powershell.codeFormatting.pipelineIndentationStyle": "None", "powershell.codeFormatting.preset": "OTBS", "powershell.codeFormatting.useCorrectCasing": true, "powershell.codeFormatting.whitespaceBetweenParameters": true, // breaks // "powershell.codeFormatting.whitespaceBetweenParameters": false, // works "powershell.developer.editorServicesLogLevel": "Diagnostic", "powershell.enableProfileLoading": true, "powershell.integratedConsole.suppressStartupBanner": false, "python.formatting.provider": "black", "workbench.editor.labelFormat": "medium" }mmunchandersen commentedon Nov 18, 2020
The issue has re-appeared in my setup (see below):
when I set:
"powershell.codeFormatting.whitespaceBetweenParameters": true
then
"Write-Output ($env:computername + ", " + $env:username)"
is formatted to:
"Write-Output ($env:computername ", " $env:username)"
The formatting does not happen when I set "powershell.codeFormatting.whitespaceBetweenParameters": false
The only thing I can think of is that I upgraded to powershell core 7.1
My setup:
Version: 1.51.1 (user setup)
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-10T23:34:32.027Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.19042
Name: PowerShell
Id: ms-vscode.powershell
Description: (Preview) Develop PowerShell scripts in Visual Studio Code!
Version: 2020.6.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell