zokugun / vscode-explicit-folding

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

Brackets in a string are also folded #38

Closed hdcontrino closed 3 years ago

hdcontrino commented 3 years ago

Describe the issue

I have this problem in PHP, in other languages I have not tried it. I tried to deny them in settings.json but no effect. when I have brackets in strings the logic of the folding breaks.

To reproduce

Code Example

$foo = '{any string';
$bar = 'another string';
$qux = 'last string }';

Settings

"folding": {
    "php": {
        "begin": "{",
        "end": "}"
    }
}

Expected behavior

The expected behavior should be nothing.

Screenshots

gif

Additional context

I tried to add a negation in this way: "beginRegex": "(?<!')\\{"; ... and many other ways, but all end up disabling the folding.

hdcontrino commented 3 years ago

I have solved the issue by editing my regex. It also solves another issue that I did not describe here, which are the strings with brackets inside brackets.

"folding": {
    "php": {
        "beginRegex": "[^'\"]\\{",
        "endRegex": "\\}(?!['\"])"
    }
}

I still need to solve the folding in Heredoc and Howdoc. Any suggestion?

daiyam commented 3 years ago

@hdcontrino In Heredoc, you can set "nested": false, it will avoid any foldings inside the comment.

hdcontrino commented 3 years ago

@hdcontrino In Heredoc, you can set "nested": false, it will avoid any foldings inside the comment.

Nice! Thanks