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

Indentation breaks using anything other than pipelineIndentationStyle: None using a second pipe within parenthesis #1976

Open
6 tasks done
C0smin opened this issue Feb 27, 2024 · 3 comments

Comments

@C0smin
Copy link
Contributor

C0smin commented Feb 27, 2024

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

The formatting of code breaks, not closing the indentation where it is logical. The conditions are highlighted in the Steps to reproduce section but it seems to be related to using both the pipe | and parenthesis () in multiple lines.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0.}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.86.2
x64

Extension Version

ms-vscode.powershell@2024.3.0

Steps to Reproduce

  1. Open a new file and paste this code:
1 | Select-Object (
    $_ |
        Write-Host
    )
Write-Host 'Indentation is broken'
  1. Format the document
  2. Write-Host is now indented at the same level as the closed parenthesis:
1 | Select-Object (
   $_ |
       Write-Host
   )
   Write-Host 'Indentation is broken'

Visuals

No response

Logs

No response

@SydneyhSmith
Copy link
Collaborator

@C0smin what are your formatting settings?

@SydneyhSmith SydneyhSmith transferred this issue from PowerShell/vscode-powershell Feb 28, 2024
@C0smin
Copy link
Contributor Author

C0smin commented Feb 29, 2024

Hi @SydneyhSmith, default VSCode and powershell extension, this is the only non default setting in my editor (this is global user-data settings.json):

{
    "powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline"
}

@bergmeister
Copy link
Collaborator

I can confirm I can repro with this specific setting. The thing with using different non-default settings for pipelineIndentationStyle is that your mileage might vary, it can achieve it in most cases but there are lots of edge cases that is still doesn't get, hence why it's not the default. Still great to raise it so maybe I can later look at seeing whether we can fix that. I've been doing that for a few years now but due to PowerShell's generic nature it's hard to write generic code covering all cases...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants