mtbaqer / vscode-better-folding

VS Code extension to improve your folding experience
https://marketplace.visualstudio.com/items?itemName=MohammadBaqer.better-folding
MIT License
315 stars 6 forks source link

"Show Only Region Descriptions" doesn't seem to be working #10

Open eFail opened 1 year ago

eFail commented 1 year ago

When I collapse the following code:

//#region I am a region!
let foo = "foo";
//#endregion

// #region I am also a region!
let bar = "bar";
// #endregion

I still see the keywords: image

No extension host issues are being logged as far as I can see.

Extension version 0.2.2

mtbaqer commented 1 year ago

Hey does option does not work in all cases? Like disabling it and reenabling it? What about having the description being only one word?

eFail commented 1 year ago

Can confirm disabling and re-enabling doesn't help. And it doesn't seem to be related to word count or whether or not the regions are indented. image

AndreaPontrandolfo commented 1 year ago

Also wanted to report this. Region naming abbreviation doesn't work at all.

mtbaqer commented 1 year ago

@eFail @AndreaPontrandolfo Would you mind providing more details on the case? I'm not able to reproduce it. And maybe try to disable all other extensions to see if one is interfering with it.

eFail commented 1 year ago

@mtbaqer I tried disabling all extensions except for Better Folding. Still doesn't work.

Here's the sample code I'm using: image

A few days ago I cloned the extension and did a little old-school debugging using information messages at various points in the code. I only had a few minutes to look around and I'm not familiar with VS Code extension development at all, but at first glance it was looking to me like REGION_REGEX inside regionRangesProvider.ts doesn't return any results. Not sure if that's helpful at all. Could it be as simple as a regex string needing to be tweaked?

eFail commented 1 year ago

@mtbaqer. I have solid repro steps for you. Any way you could take a look and get a fix out for this soon?

Inside VS code terminal: npx create-react-app foo

In VS Code:

  1. Click "Open Folder" and choose the new "foo" directory.
  2. Open index.js
  3. At the bottom, add this code:
    //#region Bar
    function bar(){
    }
    //#endregion
  4. Ctrl+Shift+P > "Fold All"

Observe that your extension works as expected: image

  1. But now right-click the src folder and choose "New file". Name it foo.js: image
  2. Paste in this code:

    import React from "react";
    
    export default function Foo(){
        //#region Bar
        function bar(){
        }
        //#endregion
    }
  3. Ctrl+Shift+P > "Fold All"
  4. Unfold the exported Foo function to reveal the region. Observe that extension is not working as expected. image

So it seems like the regex you're using might be breaking down somehow inside of function-based ReactJS components? I hope this can help get a fix out for this soon.