Merge pull request #226614 from BABA983/fix-146732
Resolve custom editor with canonical resourcepull/236395/head^2
commit
ad09e3d368
|
@ -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,
|
||||
|
|
|
@ -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<string, CustomEditorCapabilities>();
|
||||
|
||||
private readonly _models = new CustomEditorModelManager();
|
||||
private readonly _models: ICustomEditorModelManager;
|
||||
|
||||
private readonly _onDidChangeEditorTypes = this._register(new Emitter<void>());
|
||||
public readonly onDidChangeEditorTypes: Event<void> = 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));
|
||||
|
|
|
@ -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<string, {
|
||||
readonly viewType: string;
|
||||
|
@ -76,6 +84,7 @@ export class CustomEditorModelManager implements ICustomEditorModelManager {
|
|||
}
|
||||
|
||||
private key(resource: URI, viewType: string): string {
|
||||
resource = this._uriIdentityService.asCanonicalUri(resource);
|
||||
return `${resource.toString()}@@@${viewType}`;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue