Skip to content

[folding] Multiple FoldingProviders are called... #48526

Closed

Description

re #48352

The doc says that only one folder provider is called, in fact multiple are called and their results are merged.

 * Multiple folding can be registered for a language. In that case providers are sorted
 * by their [score](#languages.match) and the best-matching provider is used. Failure
 * of the selected provider will cause a failure of the whole operation.
 *
    vscode.languages.registerFoldingRangeProvider({ pattern: '**/*.foo' }, new class implements vscode.FoldingRangeProvider {
        provideFoldingRanges(document: vscode.TextDocument, context: vscode.FoldingContext, token: vscode.CancellationToken): vscode.ProviderResult<vscode.FoldingRange[]> {
            return [
                new vscode.FoldingRange(0, document.lineCount - 1, vscode.FoldingRangeKind.Region)
            ]
        }
    });

    vscode.languages.registerFoldingRangeProvider({ pattern: '**/*.foo' }, new class implements vscode.FoldingRangeProvider {
        provideFoldingRanges(document: vscode.TextDocument, context: vscode.FoldingContext, token: vscode.CancellationToken): vscode.ProviderResult<vscode.FoldingRange[]> {
            return [
                new vscode.FoldingRange(1, document.lineCount - 1, vscode.FoldingRangeKind.Region)
            ]
        }
    });

Activity

  1. jrieken commented on Apr 24, 2018

    @jrieken
    ContributorAuthor

    To make it worst, it will fail the whole operation if one fails...

  2. aeschli commented on Apr 30, 2018

    @aeschli
    Contributor

    made improvements to the spec. in 1.23 (and master)
    Keeping open to fix that a failing provider is gracefully handled.

  3. changed the title [-]Multiple FoldingProviders are called...[/-] [+][folding] Multiple FoldingProviders are called...[/+] on May 4, 2018
  4. added a commit that references this issue on May 4, 2018
    8ddee6e
  5. locked and limited conversation to collaborators on Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

verified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions