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

Idea: A way to fold the *first* line, in similar to "foldLastLine": true. #95

Open
HolyBlackCat opened this issue Oct 18, 2022 · 5 comments
Assignees

Comments

@HolyBlackCat
Copy link

Let's say I have this rule:

{
    "begin": "{",
    "end": "}",
}

If I apply it to:

void foo()
{
    //
}

It folds to:

void foo()
{ …

I can show or hide } using "foldLastLine", but there's currently no way to show/hide the {. I.e. no way to fold that to:

void foo() …

I think it would be nice to have something like "foldFirstLine", which moves the start of the fold one line up.

I'd then create two rules: one that matches a line that has nothing but { and whitespace ("foldFirstLine": true), and the fallback one that matches { elsewhere (false).

@daiyam daiyam self-assigned this Oct 26, 2024
daiyam added a commit that referenced this issue Oct 26, 2024
@daiyam
Copy link
Member

daiyam commented Oct 29, 2024

It's available in the newest version but I've named it foldBeforeFirstLine. More details at https://github.com/zokugun/vscode-explicit-folding/blob/master/docs/rules/begin-end.md#foldbeforefirstline

@HolyBlackCat
Copy link
Author

@daiyam Oh, nice! But it breaks when two folding markers cancel each other out on the same line.

#include <iostream>


int main()
{
    std::cout << "Hello!\n";
}

I have folding rules for both () and {}, and this is the result:

pic

Would be nice if the pairs of markers on the same line (() in this case) wouldn't activate this property.

@daiyam
Copy link
Member

daiyam commented Oct 30, 2024

Can you give me your rules?

@HolyBlackCat
Copy link
Author

"explicitFolding.rules": {
    "cpp": [
        {
            "begin": "{",
            "end": "}",
            "foldBeforeFirstLine": true,
        },
        {
            "begin": "(",
            "end": ")",
            "foldBeforeFirstLine": true,
        },
    ]
}

@daiyam
Copy link
Member

daiyam commented Oct 31, 2024

The new version (0.24.1) should be out with the fix.

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