'Possible to collapse custom regions?

Does vscode support create custom folding regions?

I have variables storing pictures in a format similar to base64, they are very large strings, my goal is to fold the not important part, leaving only some important things visible:

Example:

picture1 ="|<test1>ron[189,278,461,30]*172$461.0000000000000000000000zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzU00000000000000000000000000000000000000TzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzU"

picture2 ="|<test2>dkc[114,100,136,134]*136$136.zzzzzkM00Dzzzk007zzzXzzzzzzw0000Tzzy0007zzy7zzzzzzU0000zzzU000Dzzsm0B8Ty0000000003zzzzz8Ds04ETk000000000TzzzzykUzWV3z0000000003zzzzzxW03vxTw000040000TzzzzzrE0Dyzjk0400M0003zzzzzzz03ysAz00Ts1k001Dzzzzzzw0zvU3w0zzk7U00NzzzzzzXk/zc"

picture3 ="|<test3>zms[650,114,72,48]*180$72.kzz000000000Uzy0000000000zw000000z000000CTU000000000Czk000000000Szk000010000zzk000000001zzk000000003zzk000A00007xzk000C0000Dzzk0008k000Tzzk00080000Tzzk000E3000TzzU00003U"

Then after folding it would look like this:

picture1 ="|<test1>ron[189,278,461,30]*172..." 

picture2 ="|<test2>dkc[114,100,136,134]*136..."

picture3 ="|<test3>zms[650,114,72,48]*180...." 

Where ... is the part of the string that got folded.

My idea was to create a folding rule using regex or something similar

Star region: $ End region: "

I have found this extension: maptz.regionfolder, but looks like it doesn't support single line folding.

I have tested it with, settings.json:

"maptz.regionfolder": {
    "[txt]": {    
        "foldStartRegex": "\\$.*",         
        "foldEndRegex": "\"",         
        "disableFolding": false //Turn off #region folding for this language
    }
},

maptz

As seen in the gif, it works as long the string is multi-line, however when i return it to a single line, it doesnt.

My language doesnt support breaking strings into multiple lines.

Does vscode have built-in support for this? or someone know any other way I could achieve it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source