zokugun / vscode-explicit-folding

Customize your Folding for Visual Studio Code
MIT License
95 stars 14 forks source link

Slashes in regexes are not handled properly #90

Closed studyingegret closed 1 year ago

studyingegret commented 1 year ago

To reproduce

VSCode: 1.70.1 Explicit Folding: 0.21.0 Language: C

Code:

//a
1
2
//b

//a
3
4
//b

Rules:

"explicitFolding.rules": {
    "c": [
        {
            "beginRegex": "\\/\\/a",
            "end": "\\/\\/b",
            "foldLastLine": false
        },
    ]
}

Expected behavior: The following folding ranges appear:

//a ...
//b

//a ...
//b

Actual behavior: No folding ranges appear.

Debug information Output by `explicitFolding.debug` ``` [document] lang: c, fileName: c:\study-coding\learn-c\test\tmp2.c [main] regex: /(?<_0_0>\/\/a)|(?<_2_0>\\\/\\\/b)/g [main] line: 1, offset: 0, type: BEGIN, match: //a, regex: 0 [main] line: 6, offset: 0, type: BEGIN, match: //a, regex: 0 [document] foldings: [] ```
daiyam commented 1 year ago

try:

"explicitFolding.rules": {
    "c": [
        {
            "begin": "//a",
            "end": "//b",
            "foldLastLine": false
        },
    ]
}
studyingegret commented 1 year ago

Works with this.

studyingegret commented 1 year ago

It turns out that it's actually my fault, not the extension's: I mistyped "end" instead of "endRegex" and typed a regex for "end".

Sorry for my mistake!