Skip to content

Commit 9891afd

Browse files
Deprioritize file resource resolver to avoid resolution delays (#14917)
Introduce optional `priority` field on resource resolvers
1 parent ee0e526 commit 9891afd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/core/src/common/resource.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
1515
// *****************************************************************************
1616

17-
import { injectable, inject, named } from 'inversify';
17+
import { injectable, inject, named, postConstruct } from 'inversify';
1818
import { TextDocumentContentChangeEvent } from 'vscode-languageserver-protocol';
1919
import URI from '../common/uri';
2020
import { ContributionProvider } from './contribution-provider';
@@ -178,6 +178,11 @@ export namespace ResourceError {
178178

179179
export const ResourceResolver = Symbol('ResourceResolver');
180180
export interface ResourceResolver {
181+
/**
182+
* Resolvers will be ordered by descending priority.
183+
* Default: 0
184+
*/
185+
priority?: number;
181186
/**
182187
* Reject if a resource cannot be provided.
183188
*/
@@ -195,6 +200,11 @@ export class DefaultResourceProvider {
195200
protected readonly resolversProvider: ContributionProvider<ResourceResolver>
196201
) { }
197202

203+
@postConstruct()
204+
init(): void {
205+
this.resolversProvider.getContributions().sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
206+
}
207+
198208
/**
199209
* Reject if a resource cannot be provided.
200210
*/

packages/filesystem/src/browser/file-resource.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ export class FileResource implements Resource {
334334

335335
@injectable()
336336
export class FileResourceResolver implements ResourceResolver {
337+
/** This resolver interacts with the VSCode plugin system in a way that can cause delays. Most other resource resolvers fail immediately, so this one should be tried late. */
338+
readonly priority = -10;
337339

338340
@inject(FileService)
339341
protected readonly fileService: FileService;

0 commit comments

Comments
 (0)