Skip to content

Commit

Permalink
allow to ask if a document content provider already exists, prep for #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Dec 20, 2018
1 parent 1386fba commit 11a6795
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/vs/editor/common/services/resolverService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export interface ITextModelService {
* Registers a specific `scheme` content provider.
*/
registerTextModelContentProvider(scheme: string, provider: ITextModelContentProvider): IDisposable;

/**
* Check if a provider for the given `scheme` exists
*/
hasTextModelContentProvider(scheme: string): boolean;
}

export interface ITextModelContentProvider {
Expand Down
4 changes: 4 additions & 0 deletions src/vs/editor/standalone/browser/simpleServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export class SimpleEditorModelResolverService implements ITextModelService {
};
}

public hasTextModelContentProvider(scheme: string): boolean {
return false;
}

private findModel(editor: ICodeEditor, resource: URI): ITextModel | null {
let model = editor.getModel();
if (model && model.uri.toString() !== resource.toString()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class ResourceModelCollection extends ReferenceCollection<Promise<ITextEditorMod
});
}

hasTextModelContentProvider(scheme: string): boolean {
return this.providers[scheme] !== undefined;
}

private resolveTextModelContent(key: string): Promise<ITextModel> {
const resource = URI.parse(key);
const providers = this.providers[resource.scheme] || [];
Expand Down Expand Up @@ -162,4 +166,8 @@ export class TextModelResolverService implements ITextModelService {
registerTextModelContentProvider(scheme: string, provider: ITextModelContentProvider): IDisposable {
return this.resourceModelCollection.registerTextModelContentProvider(scheme, provider);
}

hasTextModelContentProvider(scheme: string): boolean {
return this.resourceModelCollection.hasTextModelContentProvider(scheme);
}
}

0 comments on commit 11a6795

Please sign in to comment.