diff --git a/src/vs/workbench/api/browser/mainThreadCustomEditors.ts b/src/vs/workbench/api/browser/mainThreadCustomEditors.ts index cd15f673c29..965e3089a96 100644 --- a/src/vs/workbench/api/browser/mainThreadCustomEditors.ts +++ b/src/vs/workbench/api/browser/mainThreadCustomEditors.ts @@ -44,6 +44,7 @@ import { ResourceWorkingCopy } from '../../services/workingCopy/common/resourceW import { IWorkingCopy, IWorkingCopyBackup, IWorkingCopySaveEvent, NO_TYPE_ID, WorkingCopyCapabilities } from '../../services/workingCopy/common/workingCopy.js'; import { IWorkingCopyFileService, WorkingCopyFileEvent } from '../../services/workingCopy/common/workingCopyFileService.js'; import { IWorkingCopyService } from '../../services/workingCopy/common/workingCopyService.js'; +import { IUriIdentityService } from '../../../platform/uriIdentity/common/uriIdentity.js'; const enum CustomEditorModelType { Custom, @@ -73,6 +74,7 @@ export class MainThreadCustomEditors extends Disposable implements extHostProtoc @IEditorService private readonly _editorService: IEditorService, @IInstantiationService private readonly _instantiationService: IInstantiationService, @IWebviewWorkbenchService private readonly _webviewWorkbenchService: IWebviewWorkbenchService, + @IUriIdentityService private readonly _uriIdentityService: IUriIdentityService, ) { super(); @@ -197,7 +199,7 @@ export class MainThreadCustomEditors extends Disposable implements extHostProtoc } try { - await this._proxyCustomEditors.$resolveCustomEditor(resource, handle, viewType, { + await this._proxyCustomEditors.$resolveCustomEditor(this._uriIdentityService.asCanonicalUri(resource), handle, viewType, { title: webviewInput.getTitle(), contentOptions: webviewInput.webview.contentOptions, options: webviewInput.webview.options, diff --git a/src/vs/workbench/contrib/customEditor/browser/customEditors.ts b/src/vs/workbench/contrib/customEditor/browser/customEditors.ts index 464f9a8cb19..d9bd443af2c 100644 --- a/src/vs/workbench/contrib/customEditor/browser/customEditors.ts +++ b/src/vs/workbench/contrib/customEditor/browser/customEditors.ts @@ -21,7 +21,7 @@ import { IUriIdentityService } from '../../../../platform/uriIdentity/common/uri import { DEFAULT_EDITOR_ASSOCIATION, EditorExtensions, GroupIdentifier, IEditorFactoryRegistry, IResourceDiffEditorInput } from '../../../common/editor.js'; import { DiffEditorInput } from '../../../common/editor/diffEditorInput.js'; import { EditorInput } from '../../../common/editor/editorInput.js'; -import { CONTEXT_ACTIVE_CUSTOM_EDITOR_ID, CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE, CustomEditorCapabilities, CustomEditorInfo, CustomEditorInfoCollection, ICustomEditorService } from '../common/customEditor.js'; +import { CONTEXT_ACTIVE_CUSTOM_EDITOR_ID, CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE, CustomEditorCapabilities, CustomEditorInfo, CustomEditorInfoCollection, ICustomEditorModelManager, ICustomEditorService } from '../common/customEditor.js'; import { CustomEditorModelManager } from '../common/customEditorModelManager.js'; import { IEditorGroup, IEditorGroupContextKeyProvider, IEditorGroupsService } from '../../../services/editor/common/editorGroupsService.js'; import { IEditorResolverService, IEditorType, RegisteredEditorPriority } from '../../../services/editor/common/editorResolverService.js'; @@ -37,7 +37,7 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ private readonly _editorResolverDisposables = this._register(new DisposableStore()); private readonly _editorCapabilities = new Map(); - private readonly _models = new CustomEditorModelManager(); + private readonly _models: ICustomEditorModelManager; private readonly _onDidChangeEditorTypes = this._register(new Emitter()); public readonly onDidChangeEditorTypes: Event = this._onDidChangeEditorTypes.event; @@ -55,6 +55,8 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ ) { super(); + this._models = new CustomEditorModelManager(this.uriIdentityService); + this._contributedEditors = this._register(new ContributedCustomEditors(storageService)); // Register the contribution points only emitting one change from the resolver this.editorResolverService.bufferChangeEvents(this.registerContributionPoints.bind(this)); diff --git a/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.ts b/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.ts index 66d5b2b5989..7b5219d5e07 100644 --- a/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.ts +++ b/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.ts @@ -6,9 +6,17 @@ import { createSingleCallFunction } from '../../../../base/common/functional.js'; import { IReference } from '../../../../base/common/lifecycle.js'; import { URI } from '../../../../base/common/uri.js'; +import { IUriIdentityService } from '../../../../platform/uriIdentity/common/uriIdentity.js'; import { ICustomEditorModel, ICustomEditorModelManager } from './customEditor.js'; export class CustomEditorModelManager implements ICustomEditorModelManager { + private readonly _uriIdentityService: IUriIdentityService; + + constructor( + uriIdentityService: IUriIdentityService, + ) { + this._uriIdentityService = uriIdentityService; + } private readonly _references = new Map