zokugun / vscode-explicit-folding

Customize your Folding for Visual Studio Code
MIT License
103 stars 15 forks source link

Second terminator doesn't foldLastLine when Begin line has two matches #120

Open TonyGravagno opened 7 hours ago

TonyGravagno commented 7 hours ago

Two rules (first and second) have a Begin match on the same line. At the end of the block, the inside (second) End is consumed by foldLastLine, but the outside (first) End is not.

To reproduce

Code Example

   static read(key: string) {
        let person: Person = new Person({   // first BEGIN on parenthesis, second on brace
            name: "Jane Doe",
            country: "USA",
            birthDate: new Date("6/7/1967"),
            numberOfPets: 2,
            petNames: ["Minnie", "Mickey"],
            hasCar: true,
        }       // is consumed with foldLine
        )       // should also be consumed with foldLastLine
        return person;
    };

Settings

"*": [
  {
    "foldLastLine": true
  }
],
...
{
  "beginRegex": "{$",
  "endRegex": "(\\}(,|;|)$)",
  "nested": true
},
...
{
  "begin": "(",
  "end": ")",
  "nested": true,
},

Expected behavior

Single folded line that considers all End matches

Actual

Single folded line consumes brace, does not consume closing parenthesis.
Note that the folding does process the brace on line 11 and the parenthesis on line 12. It just doesn't include the parenthesis in the handling of the foldLastLine processing.

[document] foldings: [{"start":4,"end":11,"kind":3},{"start":4,"end":12,"kind":3} ...

image

daiyam commented 6 hours ago

"foldLastLine": true alone does nothing... It's an optional property of a rule.

{"start":4,"end":11,"kind":3} and {"start":4,"end":12,"kind":3} start at the same line. They behave the same but you see a difference because {"start":4,"end":11,"kind":3} is simply ignored by the foldings displayer.