Skip to content

Commit

Permalink
web - fix cyclic dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Jun 1, 2020
1 parent 8a6c086 commit 2c1871d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/vs/workbench/services/editor/browser/editorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
@IConfigurationService private readonly configurationService: IConfigurationService,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
@IModelService private readonly modelService: IModelService
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) {
super();

Expand Down Expand Up @@ -927,6 +926,15 @@ export class EditorService extends Disposable implements EditorServiceImpl {
throw new Error('Unknown input type');
}

private _modelService: IModelService | undefined = undefined;
private get modelService(): IModelService | undefined {
if (!this._modelService) {
this._modelService = this.instantiationService.invokeFunction(accessor => accessor.get(IModelService));
}

return this._modelService;
}

private asCanonicalEditorResource(resource: URI): URI {
// We prefer to use the canonical form unless we know that a model
// for the given URI already exists.
Expand All @@ -936,7 +944,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
// the URI. As such we ensure that any editor that is being opened
// will use the same canonical form of the URI.
let canonicalResource: URI;
if (this.modelService.getModel(resource)) {
if (this.modelService?.getModel(resource)) {
// TODO@Ben remove this check once canonical URIs are adopted in ITextModelResolerService
canonicalResource = resource;
} else {
Expand Down

0 comments on commit 2c1871d

Please sign in to comment.