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

Incorrect matching / folding when using other folding extensions #118

Open
edgimar opened this issue Oct 18, 2024 · 4 comments
Open

Incorrect matching / folding when using other folding extensions #118

edgimar opened this issue Oct 18, 2024 · 4 comments

Comments

@edgimar
Copy link

edgimar commented Oct 18, 2024

Describe the issue

When using an extension like Better Folding or rust-analyzer, it can happen that you end up with folds in your file that do not originate from the explicit folding extension. When I define folds using the explicit folding extension, these are typically larger-scale folds that describe a kind of nested outline of the code, and I would like to be able to fold these defined folds independent of the folds coming from other sources.

I am using explicitfolding.rules with several nested separatorRegex rules to match lines staring with //| and having varying numbers of * characters to indicate nesting level. Specifically, I am using this:

    "explicitFolding.rules": {
        "rust": {
            "separatorRegex": "\\s*\\/\\/\\| \\*(?=\\s|$)",
            "strict": "never",
            "nested": [
                {
                    "separatorRegex": "\\s*\\/\\/\\| \\*\\*(?=\\s|$)",
                    "nested": [
                        {
                            "separatorRegex": "\\s*\\/\\/\\| \\*\\*\\*(?=\\s|$)",
                            "nested": [
                                {
                                    "separatorRegex": "\\s*\\/\\/\\| \\*\\*\\*\\*(?=\\s|$)",
                                    "nested": [
                                        {
                                            "separatorRegex": "\\s*\\/\\/\\| \\*\\*\\*\\*\\*(?=\\s|$)",
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    },

Two concerns:

  1. as mentioned above, it would be nice if there were commands available to fold/unfold (e.g. recursively) ONLY the folds that correspond to any of the regexes, ignoring all other sources of folding.
  2. It appears that there is some kind of interaction with Better Folding and/or rust-analyzer that prevents the regex from reliably being detected. See the following image that demonstrates this:

image

@edgimar edgimar changed the title Incorrect matching / folding when using the Better Folding extension Incorrect matching / folding when using other folding extensions Oct 18, 2024
@daiyam
Copy link
Member

daiyam commented Oct 18, 2024

Have you tried to check if your config does what you want by using the setting "editor.defaultFoldingRangeProvider": "zokugun.explicit-folding", and disabling those extensions?

@edgimar
Copy link
Author

edgimar commented Oct 19, 2024

Have you tried to check if your config does what you want by using the setting "editor.defaultFoldingRangeProvider": "zokugun.explicit-folding", and disabling those extensions?

Yes, that is what I'm currently doing, but I see it as a workaround, since it shouldn't be required to disable the folding provided by rust-analyzer in order to use explicit folding (which appears to be what the effect of setting editor.defaultFoldingRangeProvider is).

@daiyam
Copy link
Member

daiyam commented Oct 19, 2024

Can you give me an example? So that I can test and see how I can fix it.

@daiyam
Copy link
Member

daiyam commented Oct 26, 2024

+1

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

No branches or pull requests

2 participants