Skip to content

multi-root: workspace-folder explicitFolding.rules ignored for FortranFreeForm (falls back to /a^) #151

@xanfus

Description

@xanfus

Describe the issue

In a multi-root workspace, folder-level explicitFolding.rules from .vscode/settings.json can be ignored during language-scoped rule resolution.

When this happens, debug output shows fallback regex /a^/ and no foldings are produced, even though workspaceFolderValue contains valid rules.

To reproduce

  • VSCode: Cursor (VS Code-compatible; reproduced on current installation)
  • Explicit Folding: 0.24.3
  • Language: FortranFreeForm
  • Language Provider: Modern Fortran (fortran-lang.linter-gfortran)

Code Example

SUBROUTINE explicit_fold_probe()
  {{{ marker
  IF ( .TRUE. ) THEN
     PRINT *, "inside"
  ENDIF
  }}} marker
END SUBROUTINE explicit_fold_probe

Settings

{
  "editor.foldingStrategy": "auto",
  "editor.defaultFoldingRangeProvider": "zokugun.explicit-folding",
  "explicitFolding.debug": true,
  "explicitFolding.rules": [
    {
      "begin": "{{{",
      "end": "}}}"
    }
  ]
}

Repro context:

  • Multi-root workspace with folders:
    • /home/alpha/palm_development
    • /home/alpha/modeling/source2/Poisson
  • Settings file:
    • /home/alpha/palm_development/.vscode/settings.json
  • Test file:
    • /home/alpha/palm_development/explicit_folding_synthetic.f90

Expected behavior

Configured rules should be applied and produce fold ranges in FortranFreeForm files.
Debug output should show a compiled regex from configured rules (not /a^/).

Screenshots

N/A (using debug output logs)

Observed output:

[document] lang: FortranFreeForm, fileName: explicit_folding_synthetic.f90
[main] regex: /a^/
[document] foldings: []

Additional context

Runtime inspection indicated:

  • config.inspect('rules') had non-empty workspaceFolderValue
  • language rule resolution still returned an empty rules array
  • provider was built with ruleCount: 0

A local fix that resolves configuration with URI-scoped lookups in multi-root context fixes the issue:

  • workspace.getConfiguration(CONFIG_KEY, referenceUri)
  • workspace.getConfiguration(CONFIG_KEY, { languageId, uri: referenceUri })

After this change, debug output shows compiled regex and foldings as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions