allow to ask if a document content provider already exists, prep for #65400
parent
1386fba3be
commit
11a679521c
|
@ -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 {
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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] || [];
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue