Home > Software design >  how to use Indentation folding strategy and custom folding rules?
how to use Indentation folding strategy and custom folding rules?

Time:11-27

I write some code on GDscript which is similar to python. It has an indentation folding strategy that is fine.

But I also like #region which is very useful when need to split code into sections: variables, setters and getters, public functions...

I found several extensions which can manage folding strategy, but they have a side-effect: The indentation folding strategy is gone. The only way I found is to write some comment or special symbols when folding should be ended.

"explicitFolding.rules": {
    "gdscript": [
        {
            "begin": "#spoiler",
            "end": "#end"
        },
        {
            "begin": "func",
            "endRegex": "\t$"
        }
    ]
},

But can I use indentation folding strategy and region folding together in vs-code?

CodePudding user response:

So to solve that, need to change folding rules in language-extension settings.

C:\Users\usr\.vscode\extensions\geequlim.godot-tools-1.1.2\configurations\gdscript-configuration.json

Now, need to put this to end of language settings:

"folding": {
    "offSide": true,
    "markers": {
        "start": "#\\s*region\\b",
        "end": "#\\s*end\\b"
    }
}

Or what you need. Actually, I notice that there already was some Implementation of #region, but a bit harder to match that pattern. Sorry for wasting ur time.

  • Related