Skip to content

Commit 2c1871d

Browse files
author
Benjamin Pasero
committed
web - fix cyclic dependency
1 parent 8a6c086 commit 2c1871d

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/vs/workbench/services/editor/browser/editorService.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
7777
@IConfigurationService private readonly configurationService: IConfigurationService,
7878
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
7979
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
80-
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
81-
@IModelService private readonly modelService: IModelService
80+
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
8281
) {
8382
super();
8483

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

929+
private _modelService: IModelService | undefined = undefined;
930+
private get modelService(): IModelService | undefined {
931+
if (!this._modelService) {
932+
this._modelService = this.instantiationService.invokeFunction(accessor => accessor.get(IModelService));
933+
}
934+
935+
return this._modelService;
936+
}
937+
930938
private asCanonicalEditorResource(resource: URI): URI {
931939
// We prefer to use the canonical form unless we know that a model
932940
// for the given URI already exists.
@@ -936,7 +944,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
936944
// the URI. As such we ensure that any editor that is being opened
937945
// will use the same canonical form of the URI.
938946
let canonicalResource: URI;
939-
if (this.modelService.getModel(resource)) {
947+
if (this.modelService?.getModel(resource)) {
940948
// TODO@Ben remove this check once canonical URIs are adopted in ITextModelResolerService
941949
canonicalResource = resource;
942950
} else {

0 commit comments

Comments
 (0)