Skip to content

PowerShell Extension 1.8.1 breaks editor folding on region tags #1428

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

Closed
msm-fc opened this issue Jul 11, 2018 · 22 comments · Fixed by #1430
Closed

PowerShell Extension 1.8.1 breaks editor folding on region tags #1428

msm-fc opened this issue Jul 11, 2018 · 22 comments · Fixed by #1430
Labels
Issue-Bug A bug to squash.

Comments

@msm-fc
Copy link

msm-fc commented Jul 11, 2018

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
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[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
@rjmholt
Copy link
Contributor

rjmholt commented Jul 11, 2018

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

@rjmholt rjmholt added the Issue-Bug A bug to squash. label Jul 11, 2018
@glennsarti
Copy link
Contributor

glennsarti commented Jul 12, 2018

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",

@rjmholt
Copy link
Contributor

rjmholt commented Jul 12, 2018

Thanks @glennsarti!

@stukey
Copy link

stukey commented Jul 12, 2018

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).

@glennsarti
Copy link
Contributor

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

@stukey
Copy link

stukey commented Jul 12, 2018

@glennsarti Great thanks Glenn.

glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jul 12, 2018
… whitespace

Previously the code folding feature would fail to find region blocks starting
with `Region` or ending with `EndRegion`.  This was due to the regex only
looking for lower case.  This commit updates the start and end region
detection to use a similar regex to that of the VS Code default, defined in
microsoft/vscode@64186b0

Previously the code folding had trouble detecting the beginning of comment
blocks and regions which were not indented.  This was due to the empty line
regex expecting at least one whitespace character to be considered "an empty
line".  This commit modifies the empty line regex to also allow an empty string
which is indeed, an empty line.
@glennsarti
Copy link
Contributor

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 (microsoft/vscode@64186b0)

glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jul 12, 2018
…itespace correctly

Previously the code folding feature would fail to find region blocks starting
with `Region` or ending with `EndRegion`.  This was due to the regex only
looking for lower case.  This commit updates the start and end region
detection to use a similar regex to that of the VS Code default, defined in
microsoft/vscode@64186b0

Previously the code folding had trouble detecting the beginning of comment
blocks and regions which were not indented.  This was due to the empty line
regex expecting at least one whitespace character to be considered "an empty
line".  This commit modifies the empty line regex to also allow an empty string
which is indeed, an empty line.
@glennsarti
Copy link
Contributor

@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

@stukey
Copy link

stukey commented Jul 12, 2018

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)?

@glennsarti
Copy link
Contributor

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

@wsmelton
Copy link

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

@glennsarti
Copy link
Contributor

Excellent!! Thankyou!

@stukey
Copy link

stukey commented Jul 12, 2018

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

@glennsarti
Copy link
Contributor

@rjmholt and @rkeithhill will be able to answer that

@wsmelton
Copy link

@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.

@stukey
Copy link

stukey commented Jul 12, 2018

Thanks @wsmelton !

@rjmholt
Copy link
Contributor

rjmholt commented Jul 12, 2018

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

glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jul 13, 2018
…itespace correctly

Previously the code folding feature would fail to find region blocks starting
with `Region` or ending with `EndRegion`.  This was due to the regex only
looking for lower case.  This commit updates the start and end region
detection to use a similar regex to that of the VS Code default, defined in
microsoft/vscode@64186b0

Previously the code folding had trouble detecting the beginning of comment
blocks and regions which were not indented.  This was due to the empty line
regex expecting at least one whitespace character to be considered "an empty
line".  This commit modifies the empty line regex to also allow an empty string
which is indeed, an empty line.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jul 13, 2018
…itespace correctly

Previously the code folding feature would fail to find region blocks starting
with `Region` or ending with `EndRegion`.  This was due to the regex only
looking for lower case.  This commit updates the start and end region
detection to be case insensitive, similar to that defined in
microsoft/vscode@64186b0

Previously the code folding had trouble detecting the beginning of comment
blocks and regions which were not indented.  This was due to the empty line
regex expecting at least one whitespace character to be considered "an empty
line".  This commit modifies the empty line regex to also allow an empty string
which is indeed, an empty line.
glennsarti added a commit to glennsarti/vscode-powershell that referenced this issue Jul 13, 2018
…hitespace

Previously the code folding feature would fail to find region blocks starting
with `Region` or ending with `EndRegion`.  This was due to the regex only
looking for lower case.  This commit updates the start and end region
detection to be case insensitive, similar to that defined in
microsoft/vscode@64186b0

This commit adds has strict whitespace rules for the region/endregion keyword
which means only `#region` will match whereas `# region` will not.

Previously the code folding had trouble detecting the beginning of comment
blocks and regions which were not indented.  This was due to the empty line
regex expecting at least one whitespace character to be considered "an empty
line".  This commit modifies the empty line regex to also allow an empty string
which is indeed, an empty line.
@econba
Copy link

econba commented Jul 13, 2018

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.

@glennsarti
Copy link
Contributor

glennsarti commented Jul 13, 2018

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

Expanded Collapsed
image image

@econba
Copy link

econba commented Jul 13, 2018

@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.

TylerLeonhardt pushed a commit that referenced this issue Jul 16, 2018
…1430)

Previously the code folding feature would fail to find region blocks starting
with `Region` or ending with `EndRegion`.  This was due to the regex only
looking for lower case.  This commit updates the start and end region
detection to be case insensitive, similar to that defined in
microsoft/vscode@64186b0

This commit adds has strict whitespace rules for the region/endregion keyword
which means only `#region` will match whereas `# region` will not.

Previously the code folding had trouble detecting the beginning of comment
blocks and regions which were not indented.  This was due to the empty line
regex expecting at least one whitespace character to be considered "an empty
line".  This commit modifies the empty line regex to also allow an empty string
which is indeed, an empty line.
@msm-fc
Copy link
Author

msm-fc commented Jul 18, 2018

@glennsarti using [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

@rjmholt
Copy link
Contributor

rjmholt commented Jul 27, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants