VscodeAdblockSyntax
VscodeAdblockSyntax copied to clipboard
Anyway to fold / collapse just for organization purpose inside a uBO filter with VscodeAdblackSyntax ?
Hi, We are editing uBO filters in VS Code using VscodeAdblackSyntax. Can we use a symbol or a formatting to fold/collapse sections for presentation clarity?
Currently, we are using this presentation format:
!=== : as Heading 1 ===
! : as Heading 2
!!: as Heading 3
Here is an example:
It is not ideal because there is no folding / collapse possibility.
VscodeAdblackSyntax offers folding for pre-parsing directives like !#if / !#endif
but pre-parsing directives are for coding purposes, not just display purposes. Is there a better way than writting this:
Currently, folding is only available for preprocessor directives, and there is no option to configure custom folding in the extension.
Grouping and categorizing rules are planned features, and I think we don’t anticipate implementing these in the near future.
Our filter team uses the Comment Anchors extension for categorization: Comment Anchors on Visual Studio Marketplace.
Could we add the VS Code built-in code folding feature (#region / #endregion) for AdBlock filter files?
AutoHotKey Plus Plus extension for VS Code is providing the VS Code folding #region / #endregion for .ahk files. This extension has the same purpose as VscodeAdblackSyntax for Adblock filter files but for AutoHotKey files.
Currently, folding is only available for preprocessor directives, and there is no option to configure custom folding in the extension.
Grouping and categorizing rules are planned features, and I think we don’t anticipate implementing these in the near future.
Our filter team uses the Comment Anchors extension for categorization: Comment Anchors on Visual Studio Marketplace.
Willing to update this to follow the vscode's marker format for other languages? A 3rd party extension shouldn't be needed when most IDE's follow a pretty consistent format.
If you're willing to put in the PR it's just a quick update of language-configuration.json file to update
folding.markers.start to:
^\\s*!(?:#if\\s.+$|\\s*#?region\\b)
and folding.markers.end to:
^\\s*!(?:#endif\\s*$|\\s*#?endregion\\b)
This should make cold folding very intuitive. In addition to existing '!#if ' and '!#endif' (start/end respectively), it adds the start and end of !region/!endregion and !#region/!#endregion (with optional spaces)
My suggested change above wouldn't work PERFECTLY to achieve your exact current formatting, but if you NEED to use this exact format, I'm not sure if you're aware, but you can manually create folding ranges from a selection. I didn't know this existed until just now. Of course, this isn't helpful for teams that maintain filterlists, but if it's just you, better than nothing...
To illustrate, when you use AutoHotKey Plus Plus extension for VS Code, #region #endregion collapse is built-in :
This is convenient to manage a large file of AHK code.
I would love to have the same for Adblock files.
If you're willing to put in the PR it's just a quick update of language-configuration.json file to update
folding.markers.start to: ^\s*!(?:#if\s.+$|\s*#?region\b)
and folding.markers.end to: ^\s*!(?:#endif\s*$|\s*#?endregion\b)
Can I add this to VscodeAdblackSyntax configuration to get this #region / #enregion folding? or it has to be done by a dev then this will be too complex for me sadly.
I tried using the manual folding range, as I cannot develop an Adblock filter without code folding. Unfortunately, it is not usable as my files are synchronized. So even for a single user, you cannot use this . As you pointed out it is also not usable in teamwork which is frequent for Adblock filters. So having the #region #endregion auto folding in the Adblock file is still a must-have.
folding.markers.start to:
^\\s*!(?:#if\\s.+$|\\s*#?region\\b)and folding.markers.end to:
^\\s*!(?:#endif\\s*$|\\s*#?endregion\\b)
@minig0d With this folding approach, the likely issue is that the markers won't form proper pairs. In other words, #if and #endif won’t be tightly coupled. Instead, for example, VS Code might consider an #endregion as the closing marker for an #if, and so on.
The ideal solution would likely involve making folding pairs (start and end regex) configurable through the settings as an array. Then, we could programmatically define the ranges using the provideFoldingRanges function.