Vscode-powershell: PowerShell Extension 1.8.1 breaks editor folding on region tags

Created on 11 Jul 2018  Â·  22Comments  Â·  Source: PowerShell/vscode-powershell

System Details

  • Operating system name and version: Windows 10.1803.17134.137
  • VSCode Version: 1.25.0
  • PowerShell extension version: 1.8.1
  • Output from $PSVersionTable:
    Name Value
    ---- -----
    PSVersion 5.1.17134.137
    PSEdition Desktop
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
    BuildVersion 10.0.17134.137
    CLRVersion 4.0.30319.42000
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1

$pseditor.EditorServicesVersion
code --list-extensions --show-versions
$PSVersionTable
1.25.0
0f080e5267e829de46638128001aeb7ca2d6d50e
x64

Major Minor Build Revision


1 8 1 0
cdsama.[email protected]
dakara.[email protected]
emmanuelbeziat.[email protected]
GrapeCity.[email protected]
ilich8086.[email protected]
mechatroner.[email protected]
ms-vscode.[email protected]
ms-vscode.[email protected]
PKief.[email protected]
schneiderpat.[email protected]
tuxtina.[email protected]

Key : PSVersion
Value : 5.1.17134.137
Name : PSVersion

Key : PSEdition
Value : Desktop
Name : PSEdition

Key : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name : PSCompatibleVersions

Key : BuildVersion
Value : 10.0.17134.137
Name : BuildVersion

Key : CLRVersion
Value : 4.0.30319.42000
Name : CLRVersion

Key : WSManStackVersion
Value : 3.0
Name : WSManStackVersion

Key : PSRemotingProtocolVersion
Value : 2.3
Name : PSRemotingProtocolVersion

Key : SerializationVersion
Value : 1.1.0.1
Name : SerializationVersion

Issue Description

Searched for existing issues, didn't find anything.
Others in the chat room also confirmed
Reproduced with latest Insiders Build of vscode.

Steps to Reproduce:

  1. Install vscode
  2. Open a powershell script file containing working region and endregion tags
  3. Observe that the editor folding works
  4. Install Powershell Extension (ms-vscode.powershell) version 1.8.1
  5. Relaunch vscode
  6. Observe that editor folding is not working
Issue-Bug

Most helpful comment

@stukey Thanks. That makes it make easier to track down what's going on. I've repro'd locally and working on a fix.

All 22 comments

Thanks for opening an issue @msm-fc!

We think 1.8.0 broke this as well.

VSCode seems to implement its own #region folding, so maybe this got overridden?

/cc @glennsarti @rkeithhill

The new syntax folder is all or nothing, i.e. when active, only the folding ranges supplied will be used. None of the vscode default ones will be used.

The vscode region folding is defined here;
https://github.com/Microsoft/vscode/blob/master/extensions/powershell/language-configuration.json#L26-L31

The syntax folder uses this;
https://github.com/PowerShell/vscode-powershell/blob/master/src/features/Folding.ts#L425-L426

One difference I see is casing.

However without the source document debugging/reproing this issue is almost impossible.

@msm-fc

  1. Can you please provide the document you used when you saw the issue
  2. Preferably adds some screenshots with the syntax-folding enabled and disabled (requires a VSCode reload to take effect)

VSCode setting;
"powershell.codeFolding.enable": "false",

Thanks @glennsarti!

I am experiencing this issue too.

Syntax folding enabled (powershell.codeFolding.enable = true):

9d4bfac6-4166-4e1a-a52e-dc721fe22e5a

Syntax folding disabled (powershell.codeFolding.enable = false):

6f0d0f44-7ec9-4ffd-a2b1-f42fbec9f287

I noticed the problem with version 1.8.0 of the PowerShell extension too. Also version 1.8.0 or 1.8.1 appears to have made Region Folding case-sensitive again. So even with ‘powershell.codeFolding.enable’ set to false, #Region #EndRegion sections are not folded but #region #endregion sections are folded. Prior to 1.8.0 I noticed that Region Folding became non case-sensitive (which was better).

@stukey Thanks. That makes it make easier to track down what's going on. I've repro'd locally and working on a fix.

@glennsarti Great thanks Glenn.

So PR #1430 is up to fix the region case sensitivity problem.

The PowerShell region folding doesn't actually come from the PowerShell extension, it's embedded in VSCode by default, which is why the behaviour can seem odd i.e. Code Folding Disabled, with VSCode 1.23 and PowerShell Extension 1.8.1 will have case sensitive region folding :-)

Interestingly, VSCode only fixed that in 1.24.0 which is probably why I missed it orginally (https://github.com/Microsoft/vscode/commit/64186b0a262f0ff89a060cf8dbbf8de7ff831a00)

@stukey If you know how to use one-off extension builds, https://ci.appveyor.com/project/PowerShell/vscode-powershell-cs82i/build/1.8.1-insiders-236/artifacts has the VSIX file for that PR

Thanks @glennsarti I don’t know how to do that so I will wait for the release version. Just so I’m clear do I still have to disable syntax folding in order for region folding to work properly in ps1 scripts (as it did before 1.8.0)?

Yes. Once the new version is released, you can re-enable syntax folding.

@glennsarti I pulled down the VSIX file and can confirm that region folding is working again under that artifact.

Excellent!! Thankyou!

When will this be merged into a release version? I have no idea how that works...

@rjmholt and @rkeithhill will be able to answer that

@stukey there is a menu option to "install from vsix file" that lets you manually add the extension:
image

Just download the file and browse to it when prompted. There is another prompt that you have an "earlier version" of the extension but just let it overwrite that version.

Thanks @wsmelton !

Also @stukey if you have the VSIX file downloaded, you can install it in the CLI like this:

code --install-extension /path/to/PowerShell-insiders.vsix

I've installed the update and can also confirm that code folding an regions is working again and it is non case sensitiv. But unfortunately I recognized that code folding on regions now fails if a comment line follows the region start:
image
only the commented line is folded:
image
Can someone test to confirm?

EDIT: seems that only the first region with a following comment line if affected. All other regions are folding correct.

I can't repro that. Are you able to post the entire script?

| Expanded | Collapsed |
| --- | --- |
| image | image |

@glennsarti OK, thanks for testing.
I've found out that only the first region is affected so I think it is a local issue.
I have this issue in several scripts but was also not able to reproduce it by now in an new script.
Unfortunately I cannot post the entire script because they are all sscripts for customers with many data of the customers in it.

@glennsarti using ms-vscode.[email protected] with vscode 1.25.1, the issue appears resolved. Thanks!!

I'm using this test code to verify:

2018-07-18 11_34_54code-folding

image

The release went out this morning with a fix for this in it

Was this page helpful?
0 / 5 - 0 ratings