maptz.vscode.extensions.customfolding icon indicating copy to clipboard operation
maptz.vscode.extensions.customfolding copied to clipboard

Regions Only Recognized when Contained Code is Indented

Open Eunomiac opened this issue 5 years ago • 3 comments

I have these two regions defined next to each other in my javascript file, but only the second region is recognized. My linter gets angry with me if I break conventional indentation rules, so is there a way to configure custom folding so it does not require indenting the code contained in the region?

/* #region default Not a Recognized Region */
const data = super.getData();
const actorData = data.data;
const panthData = CONFIG.scion.PANTHEONS;
const godData = CONFIG.scion.GODS;
/* #endregion */

/* #region default Valid Region */
    const data = super.getData();
    const actorData = data.data;
    const panthData = CONFIG.scion.PANTHEONS;
    const godData = CONFIG.scion.GODS;
/* #endregion */

For reference, here are my settings:

"maptz.regionfolder": {
    "[javascript]": {
        "foldEnd": "/* #endregion */",
        "foldEndRegex": "/\\*[\\s]*#endregion",
        "foldStart": "/* #region [NAME] */",
        "foldStartRegex": "^[\\s]*/\\*[\\s]*#region[\\s]*(.*)[\\s]*\\*/[\\s]*$",
        "defaultFoldStartRegex": "^[\\s]*/\\*[\\s]*#region[\\s]*default\\s(.*)[\\s]*\\*/[\\s]*$"
    }
}

Eunomiac avatar Nov 26 '20 08:11 Eunomiac

Hmm. Not sure why this is happening. It doesn't happen on my system. Can you try doing the same with another language and seeing if you get the same behaviour?

maptz avatar Dec 09 '20 23:12 maptz

VS itself will do folding based on indentation, no addons required. This bug is more likely that the extension isn't working at all and you are seeing default VS behaviour.

aki-art avatar Jan 01 '21 09:01 aki-art

Hi,

Yes. I can't reproduce this behaviour I'm afraid. Are you still having issues?

maptz avatar Mar 25 '21 19:03 maptz

I also have this same issue. I wonder if that's my regex pattern but it seems like a bug though. Here is a preview of the behavior:

https://i.vgy.me/QDqoXW.gif

Which makes this unsuable as is. These are the settings I use:

"maptz.regionfolder": {
    "collapseDefaultRegionsOnOpen": true,
    "[liquid]": {
      "foldStart": "{%- # region [] -%}",
      "foldEnd": "{%- # endregion -%}",
      "foldStartRegex": "\\s*{%-\\s*#\\s*region\\s*(.*)",
      "foldEndRegex": "\\s*{%-\\s*#\\s*endregion\\s*(.*)",
      "disableFolding": false,
      "defaultFoldStartRegex": "\\s*{%-\\s*#\\s*region\\s*(collapsed)\\s*(.*)",
    }
  }

This is in a .liquid file, but I also tried in an ordinary .css file and I have the same behaviour.


Edit: actually, I found out the culprit, even though I still believe it's a bug. It seems this vscode setting: "editor.foldingStrategy": "indentation", prevents your extension to fold a region when there is no indentation within this region. Without this setting it works as expected:

image

But with this setting on, indentation behaves as expected, except the region does not fold, probably because it conflicts with the setting I mentioned (which is very important for most templating language):

image

MaxDesignFR avatar Apr 13 '23 13:04 MaxDesignFR