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

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

Closed
jrieken opened this issue Apr 24, 2018 · 2 comments
Closed

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

jrieken opened this issue Apr 24, 2018 · 2 comments
Assignees
Labels
verified Verification succeeded
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Apr 24, 2018

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)
            ]
        }
    });
@jrieken
Copy link
Member Author

jrieken commented Apr 24, 2018

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

@jrieken jrieken assigned aeschli and unassigned jrieken Apr 24, 2018
@aeschli
Copy link
Contributor

aeschli commented Apr 30, 2018

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

@aeschli aeschli added this to the May 2018 milestone Apr 30, 2018
@jrieken jrieken added the verified Verification succeeded label May 3, 2018
@aeschli aeschli closed this as completed May 4, 2018
@aeschli aeschli modified the milestones: May 2018, April 2018 May 4, 2018
@aeschli aeschli changed the title Multiple FoldingProviders are called... [folding] Multiple FoldingProviders are called... May 4, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

2 participants