zokugun / vscode-explicit-folding

Customize your Folding for Visual Studio Code
MIT License
95 stars 14 forks source link

Folding resets after restarting VS Code #111

Open Kycko opened 5 months ago

Kycko commented 5 months ago

Describe the issue

VS Code resets all the folding when I close it and open again. I've found the problem in your extention, see https://github.com/microsoft/vscode/issues/189610.

To reproduce

Fold some functions in .gs file (Google Apps Script, language mode JavaScript), close and then open again VS Code. You will see all the functions unfolded.

Code Example

function SH_get_full_range(sheet) {
    return sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns());
}

Settings

"explicitFolding.rules": {
        "javascript": [
            {
                "begin": "{",
                "end"  : "}"
            },
            {
                "begin": "`",
                "end"  : "`"
            },
            {"foldLastLine": true}
        ],
        "snippets": [
            {
                "begin": "{",
                "end"  : "}"
            },
            {
                "begin": "`",
                "end"  : "`"
            },
            {"foldLastLine": true}
        ]
    }

Expected behavior

Save the folding state after VS Code restarts.

Screenshots

image image

daiyam commented 5 months ago

Do you have the following settings?

"editor.foldingStrategy": "auto",
"editor.defaultFoldingRangeProvider": "zokugun.explicit-folding",
Kycko commented 5 months ago

foldingStrategy is set to auto by default. I've changed defaultFoldingRangeProvider to zokugun.explicit-folding, but the issue isn't solved.

Kycko commented 5 months ago

I've noticed the folding resets only in the files I see when opening VS Code. If the file is opened but it's in other tab, the folding is saved. 🤔

image

daiyam commented 5 months ago

The folding state is managed by VSCode so I would incline to say it's a VSCode bug.

I have also the issue when, sometimes, I have extra foldings. It took me a while to understand it was foldings generated by the default folding provider (before switching to my provider), then saved as "Manual Folding Ranges" by VSCode. Solution: command Remove Manual Folding Ranges

Kycko commented 5 months ago

Ran this command, didn't help me.

As I mentioned in https://github.com/microsoft/vscode/issues/189610 the folding state doesn't reset if I disable your extention. Seems there is some conflict in saved folding state and your extention when it's loaded after app start.

Maybe the logs will help?