vscode-explicit-folding icon indicating copy to clipboard operation
vscode-explicit-folding copied to clipboard

How to only apply rules to files with custom extension?

Open cesaryuan opened this issue 2 years ago • 7 comments

Describe the issue

I have a file whose ext is .jscasm. How do I only apply rules to it?

I tried the following settings, but it doesn't work.

    "explicitFolding.rules": {
        ".jscasm": [
            {
                "beginRegex": "Bytecode age: ",
                "endRegex": "Constant pool \\(size = ",
                "foldLastLine": false
            },
            {
                "beginRegex": "; #region",
                "endRegex": "; #endregion",
                "foldLastLine": true
            }
        ]
    }

Settings

    "explicitFolding.rules": {
        ".jscasm": [
            {
                "beginRegex": "Bytecode age: ",
                "endRegex": "Constant pool \\(size = ",
                "foldLastLine": false
            },
            {
                "beginRegex": "; #region",
                "endRegex": "; #endregion",
                "foldLastLine": true
            }
        ]
    }

cesaryuan avatar Nov 29 '23 12:11 cesaryuan

".jscasm" won't work. It should be the language identifier.

daiyam avatar Nov 29 '23 14:11 daiyam

".jscasm" won't work. It should be the language identifier.

Thanks for your reply! But there is no corresponding language identifier. This is a very niche file extension.

cesaryuan avatar Nov 29 '23 14:11 cesaryuan

If it's still a Javascript file, you could use explicitFolding.perFiles

daiyam avatar Nov 29 '23 17:11 daiyam

If it's still a Javascript file

It is a plaintext file. So I tried the following settings, but it not work.

    "[plaintext]": {
        "editor.foldingStrategy": "auto",
        "editor.defaultFoldingRangeProvider": "zokugun.explicit-folding",
        "explicitFolding.perFiles": {
            "*.jscasm": [
                {
                    "beginRegex": "Bytecode age: ",
                    "endRegex": "Constant pool \\(size = ",
                    "foldLastLine": false
                },
                {
                    "beginRegex": "; #region",
                    "endRegex": "; #endregion",
                    "foldLastLine": true
                }
            ]
        }
    }

By the way, explicitFolding.rules works but is for all plaintext.

.jscasm file example:

Parameter count 1
Register count 1
Frame size 8
Bytecode age: 0
    0 S> 000000CD0011448A @    0 : 80 00 00 00       CreateClosure [0], [0], #0
         000000CD0011448E @    4 : c4                Star0
219746 S> 000000CD0011448F @    5 : a9                Return
Constant pool (size = 1)
000000CD00114491: [FixedArray] in OldSpace

cesaryuan avatar Nov 30 '23 02:11 cesaryuan

".jscasm" won't work. It should be the language identifier.

the extension i am concerned with is language independent, think of it as similar to a templating language. so, sometimes i am writing in python, or md or rst in it... so, how would the explicitFolding.perFiles help in that case?

I tried the following settings, but [the ability to select only the particular file extensions] not work. - @cesaryuan at https://github.com/zokugun/vscode-explicit-folding/issues/109#issuecomment-1832993628

@ daiyam any input on that?

goyalyashpal avatar May 01 '24 14:05 goyalyashpal

I can confirm the issue with the explicitFolding.perFiles. Looking into it.

daiyam avatar Oct 26 '24 16:10 daiyam

I've found and fixed the bug... It will available in the next version

daiyam avatar Oct 26 '24 16:10 daiyam

It has been fixed in the newest version.

daiyam avatar Oct 29 '24 18:10 daiyam