zokugun / vscode-explicit-folding

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

Can't select Linebreak with regexp #8

Closed AgamlaRage closed 5 years ago

AgamlaRage commented 5 years ago

Hello,

first of all thank you so much for your extension. I feel like I was waiting one line code folding since decades!

I'm trying to creates regexp for SCSS files. But it looks like I can't select the linebreaks characters.

Regexp that is working and tested with Regexr.

    // settings.json
    "scss": [
      {
        "beginRegex": " {",
        "endRegex": "[\n| ]}",
         // "endRegex": "/[\n| ]}/g", // I also tryied this, but not working
      },
    ],

Explanation

Test code

#nav-menu-container {
  min-height: calc(100vh + 1px);
  padding-top: calc(#{$spacing} + #{$navbar-height});
  @include mbu(tablet) {
    padding: 10%;
    padding-top: calc(10% + #{$navbar-height});
    display: flex;
    align-items: center;
  }
}

With this I'm able to fold the nested block in 1 line, but not the parent element. I think my regexp is all good except the linebreak part.

Could someone help me please ?

Thx

daiyam commented 5 years ago

Hi @AgamlaRage,

I'm glad you like the extension.

I've not updated to the latest version of VSCode, but the default "editor.foldingStrategy": "auto" should fold as you like...

Maybe you can try:

{
  "beginRegex": " \\{\\s*$",
  "endRegex": "^\\s*\\}"
}
AgamlaRage commented 5 years ago

Hi @daiyam, your regexp seems to works for me! Thx

Before closing the issue, I want to propose something to you, maybe you already planed it or thought about it. You could create a markdown table, referencing the good regexp that people shared to you. Maybe that will prevent you from spending extra time telling others people like me the good regexp.

Example:

Language beginRegex endRegex
SCSS \{\s*$ ^\s*\}
Javascript
PHP

Thx again for your extension. I'll let you know if I find regexp <3