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

Using region comments, collapsing doesn't include the endregion line #5029

Open
6 tasks done
plmcgrn opened this issue Aug 19, 2024 · 1 comment
Open
6 tasks done

Comments

@plmcgrn
Copy link

plmcgrn commented Aug 19, 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

When using #region and #endregion in developing PowerShell code, there is a difference in how code collapse works in ISE vs. VS Code. In ISE, collapsing a region will also hide the endregion line. In VS Code, it will not. This leads to extraneough lines when trying to collapse all regions for easier code viewing.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.4.3
PSEdition                      Core
GitCommitId                    7.4.3
OS                             Darwin 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:04 PDT 2024; root:xn…
Platform                       Unix
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       : 299e7431-e53b-4bb8-b868-133a1dd5f18c
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

Version: 1.92.1 (Universal)
Commit: eaa41d57266683296de7d118f574d0c2652e1fc4
Date: 2024-08-07T20:16:39.455Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Darwin arm64 23.6.0

Extension Version

v2024.2.2

Steps to Reproduce

Write a region in a PowerShell script within VS Code, example:

#region: Enable archive for each mailbox
if ($mailboxes.count -gt 0) {
    foreach ($mailbox in $mailboxes) {
        try {
            $mailboxOutput = $mailbox | Enable-Mailbox -Archive
            Write-Output "Enabled archive for $($mailbox.DisplayName)"
        }
        catch {
            Write-Output "Failed to enable archive for $($mailbox.DisplayName)"
            Write-Error "Failed to enable archive for $($mailbox.DisplayName)"
            Write-Output $_.Exception
            Write-Output $_.ErrorDetails
        }        
    }    
}
#endregion: Enable archive for each mailbox

When collapsing the region, it will show two lines, not 1

#region: Enable archive for each mailbox
#endregion: Enable archive for each mailbox

Visuals

image image

Logs

No response

@plmcgrn plmcgrn added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Aug 19, 2024
@JustinGrote
Copy link
Collaborator

JustinGrote commented Aug 19, 2024

Thanks for the submission! It's certainly something we should look into in terms of the grammar, because the standard with other languages appears to fold that end part inwards. At the very least we should have a configurable option ideally if it's not a hard-baked grammar rule thing.

Javascript Example:
image

image

@JustinGrote JustinGrote added Area-Code Formatting Area-Folding and removed Needs: Triage Maintainer attention needed! labels Aug 19, 2024
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

2 participants