Open
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
I've been debugging my script for hours, and finally figured out that the format I did last time, broke my null-conditional operators as it adds spaces between the braces, for example:
$c = $a.{b}?.Trim();
Turns into
$c = $a.{ b }?.Trim();
Causing $c
to be empty/null
I fixed this manually in my script but noticed that formatting changes it back - I think this is a wrong format for this specific use-case as it breaks these operators.
Information about the operator: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.4#null-conditional-operators--and-
PowerShell Version
PS> $PSVersionTable; $Host
Name Value
---- -----
PSVersion 7.4.5
PSEdition Core
GitCommitId 7.4.5
OS Microsoft Windows 10.0.27695
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name : Visual Studio Code Host
Version : 2024.2.2
InstanceId : 7973e8e2-cbb7-4e99-98e3-9169ba600aa3
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : nl-NL
CurrentUICulture : nl-NL
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
Visual Studio Code Version
PS> code --version
1.93.1
38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
x64
Extension Version
PS> code --list-extensions --show-versions | Select-String powershell
ms-vscode.powershell@2024.2.2
Steps to Reproduce
- Write code as follows:
$c = $a.{b}?.Trim();
- Use document format in vscode
Visuals
No response
Logs
No response