zokugun / vscode-explicit-folding

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

Using a regex that matches 0 characters hungs the editor #19

Closed HolyBlackCat closed 4 years ago

HolyBlackCat commented 4 years ago

Thanks for your work on this extension!

Here's my config:

{
    "beginRegex": "\\/\\/",
    "endRegex": "(?<!\\\\)$",
},

It's intended to fold C++ single-line comments (start with //, end at the end of line, but if line ends with \, the next line is also a part of the comment).

When I use this config, the editor sort of hungs (I can't type any characters, there's no folding, but everything else works). This thing often happens when I use a bad regex that sends the parser into a near-infinite loop, but this time I'm sure the regex is fine.

After some testing, I think it happens when a regex matches 0 characters.

daiyam commented 4 years ago

@HolyBlackCat I will fix the infinity loop due to the regex matching 0 characters.

For your issue, I will add the option continuation, so you could use the config:

{
  "begin": "//",
  "continuation": "\\"
}
daiyam commented 4 years ago

@HolyBlackCat I've published the fixed extension for your issue. Feel free to reopen it if you have a problem.