Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyway to fold / collapse just for organization purpose inside a uBO filter with VscodeAdblackSyntax ? #139

Open
oeloo opened this issue Oct 25, 2024 · 6 comments
Assignees

Comments

@oeloo
Copy link

oeloo commented Oct 25, 2024

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:
image
It is not ideal because there is no folding / collapse possibility.

VscodeAdblackSyntax offers folding for pre-parsing directives like !#if / !#endif
image
but pre-parsing directives are for coding purposes, not just display purposes. Is there a better way than writting this:
image

@scripthunter7
Copy link
Member

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.

@oeloo
Copy link
Author

oeloo commented Dec 5, 2024

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.

@minig0d
Copy link

minig0d commented Jan 15, 2025

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)

@minig0d
Copy link

minig0d commented Jan 15, 2025

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...

@oeloo
Copy link
Author

oeloo commented Jan 15, 2025

To illustrate, when you use AutoHotKey Plus Plus extension for VS Code, #region #endregion collapse is built-in :
image
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.

@scripthunter7
Copy link
Member

scripthunter7 commented Jan 17, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants