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

Cannot fold two consecutive blocks #121

Open
ehehela opened this issue Dec 11, 2024 · 1 comment
Open

Cannot fold two consecutive blocks #121

ehehela opened this issue Dec 11, 2024 · 1 comment

Comments

@ehehela
Copy link

ehehela commented Dec 11, 2024

Describe the issue

I want to fold two blocks. Both are identified by the comment character #. The first block is a comment block, which is composed of consecutive line comments beginning with only one #. The second block is a code block. The code is between two comment lines. The first comment line begins with ## SECTION, signifying the start of the code block. The second comment line begins with ## !SECTION, signifying the end of the code block. The SECTION keyword is a feature of the other extension called Comment Anchors.

The problem is that when these two blocks are separated by one line, they can fold themselves, respectively. However, if the two blocks are adjacent without a seperator, only one block can be folded.

To reproduce

  • VSCode: 1.95.3
  • Explicit Folding: 0.24.1
  • Language: Julia
  • Language Provider: Julia

Code Example

Click here to see the code
# I 
# want to
# fold 
# these consecutive 
# comment lines

## SECTION - This is a comment but belong to the following block. It is a sepretor for starting of a code cell/section.
mycode = 1
is = 2
written = 3
here = 4
## !SECTION - This is a comment but belong to the previous block. It is a sepretor for ending of a code cell/section.
# I 
# want to
# fold 
# these consecutive 
# comment lines
## SECTION - This is a comment but belong to the following block. It is a sepretor for starting of a code cell/section.
mycode = 1
is = 2
written = 3
here = 4
## !SECTION - This is a comment but belong to the previous block. It is a sepretor for ending of a code cell/section.

Settings

Click here to see the settings
    "explicitFolding.rules": [
        {
            "beginRegex": "^\"\"\"$",
            "endRegex": "^\"\"\"$",
            // "autoFold": true
        },
        {
            "beginRegex": "^##(?!#) SECTION",
            "endRegex": "^##(?!#) !SECTION",
        },
        {
            "separatorRegex": "^##(?!#| ?!?SECTION).*",
        },
        {
            "beginRegex": "^(@testitem|@testsnippet)",
            "autoFold": true
        },
        {
            "indentation": true,
            "offSide": true
        },
        {
            "whileRegex": "#(?!#|=)",
            "kind": "comment",
            "foldLastLine ": false,
        },
        {
            "beginRegex": "#=",
            "endRegex": "=#$",
            "kind": "comment",
        }
    ],

Screenshots

Original texts

屏幕截图 2024-12-11 231404

Folding result (this is not the correct folding)

屏幕截图 2024-12-11 231625

Expected behavior

The expected behavior is to fold line No.1-5 (block 1), line No.7-12 (block 2), line No.13-17 (block 3) and line No.18-23 (block 4).

@ehehela
Copy link
Author

ehehela commented Dec 12, 2024

Another question is why the "autoFold": true setting is not working. See the above settings. Whether or not I comment on this setting, the docstring block will not automatically be folded. It always defaults to unfolded.

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

1 participant