From 11a679521c99daf4eaaf5de0853c8db01b5e7114 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 20 Dec 2018 12:49:09 +0100 Subject: [PATCH] allow to ask if a document content provider already exists, prep for #65400 --- src/vs/editor/common/services/resolverService.ts | 5 +++++ src/vs/editor/standalone/browser/simpleServices.ts | 4 ++++ .../textmodelResolver/common/textModelResolverService.ts | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/src/vs/editor/common/services/resolverService.ts b/src/vs/editor/common/services/resolverService.ts index 09ac4bbcf61..28aca391a32 100644 --- a/src/vs/editor/common/services/resolverService.ts +++ b/src/vs/editor/common/services/resolverService.ts @@ -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 { diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index ffc1ada1623..84cc477a801 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -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()) { diff --git a/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts b/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts index 38845a0e2fc..8d2ccf80881 100644 --- a/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts +++ b/src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts @@ -96,6 +96,10 @@ class ResourceModelCollection extends ReferenceCollection { 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); + } }