vscode-better-folding icon indicating copy to clipboard operation
vscode-better-folding copied to clipboard

Region folding stop to work with both the vscode-better-folding and vscode-explicit-folding extensions enabled

Open juarezr opened this issue 4 months ago • 0 comments

Describe the bug

  • Region folding stop to work I have both the vscode-better-folding and vscode-explicit-folding extensions enabled.
  • If I turn off the vscode-better-folding extension and reload the VSCode editor, the region folding works as it should.
  • The vscode-explicit-folding extension is used for languages that don't have region folding support only.
  • Notice that vscode-better-folding also does not respect the editor.defaultFoldingRangeProvider setting configured for any language.

To Reproduce

Steps to reproduce the behavior:

  1. Install both vscode-better-folding and vscode-explicit-folding extensions in VSCode.
  2. Configure some rules in the vscode-explicit-folding extension settings for any editor language you want.
  3. Make sure that both extensions are enabled. Reload VS Code if needed.
  4. Open a file that has the region folding matching the former rules and notice that:
    1. Sometimes just the first region folds
    2. Sometimes no region fold.
    3. Files that doesn't have vscode-explicit-folding rules configured aren't affected and work as expected.

Expected behavior

  • This extension should respect the folding when the editor.defaultFoldingRangeProvider setting.
  • One should fold/unfold regions with both extensions enabled even when the editor.defaultFoldingRangeProvider is not set.

Examples

Examples of settings and files to help explain the problem:

setttings.json

{
    "[shell]": {
        "editor.defaultFormatter": "mkhl.shfmt",
        "editor.defaultFoldingRangeProvider": "zokugun.explicit-folding",
    },
    "explicitFolding.rules": [
        {
            "shellscript": {
                "kind": "region",
                "beginRegex": "#[\\s]*region[\\s]+([\\w]+)",
                "endRegex": "#[\\s]*endregion",
            },
        }
    ]
}

example.sh

#!/bin/bash

#region Shell #1

ls -l
pwd

#endregion

#region Shell #2

whoami
man git

#endregion

## end of the file ##

my-workspace.code-workspace (workaround)

{
    "settings": {
        "betterFolding.excludedLanguages": [
            "shellscript",
        ],
    }
}

Workarounds

  1. Adding the languages with rules into the setting betterFolding.excludedLanguages works. This setting can be placed:
    1. In then workspace settings JSON file (${workspaceFolder}/my.code-workspace)
    2. User settings settings JSON file (~/.config/Code/User/settings.json)
    3. But not in the folder settings JSON file (${workspaceFolder}/.vscode/settings.json)
  2. Disable vscode-better-folding

System Information

Additional context

Thanks for this wonderful extension.

juarezr avatar Mar 26 '24 20:03 juarezr