diff --git a/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts b/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts index d67f433f8c95461e83dd7900ccacef8afafba2fd..50d4d812b76f09435fcff8148aac4ceeaeb30873 100644 --- a/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts +++ b/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.ts @@ -23,8 +23,7 @@ import { IUserDataSyncAccountService } from 'vs/platform/userDataSync/common/use import { IUserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync'; import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; -import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { ReloadWindowAction } from 'vs/workbench/browser/actions/windowActions'; +import { IHostService } from 'vs/workbench/services/host/browser/host'; const SOURCE = 'IWorkbenchExtensionEnablementService'; @@ -50,7 +49,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench @IUserDataSyncAccountService private readonly userDataSyncAccountService: IUserDataSyncAccountService, @ILifecycleService private readonly lifecycleService: ILifecycleService, @INotificationService private readonly notificationService: INotificationService, - @IInstantiationService instantiationService: IInstantiationService, + @IHostService hostService: IHostService, ) { super(); this.storageManger = this._register(new StorageManager(storageService)); @@ -62,8 +61,7 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench this.lifecycleService.when(LifecyclePhase.Restored).then(() => { this.notificationService.prompt(Severity.Info, localize('extensionsDisabled', "All installed extensions are temporarily disabled. Reload the window to return to the previous state."), [{ label: localize('Reload', "Reload"), - // Using ReloadWindowAction because depending on IHostService causes cyclic dependency - #108522 - run: () => instantiationService.createInstance(ReloadWindowAction, ReloadWindowAction.ID, ReloadWindowAction.LABEL).run() + run: () => hostService.reload() }]); }); } diff --git a/src/vs/workbench/services/extensionManagement/test/browser/extensionEnablementService.test.ts b/src/vs/workbench/services/extensionManagement/test/browser/extensionEnablementService.test.ts index 8080ace1e78cce63ab66ef6e18273c0f6a68823a..fe48d4f147de2cfc151450d69e4c3ff24d94cc6d 100644 --- a/src/vs/workbench/services/extensionManagement/test/browser/extensionEnablementService.test.ts +++ b/src/vs/workbench/services/extensionManagement/test/browser/extensionEnablementService.test.ts @@ -27,6 +27,7 @@ import { IUserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/com import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService'; +import { IHostService } from 'vs/workbench/services/host/browser/host'; function createStorageService(instantiationService: TestInstantiationService): IStorageService { let service = instantiationService.get(IStorageService); @@ -60,7 +61,7 @@ export class TestExtensionEnablementService extends ExtensionEnablementService { instantiationService.get(IUserDataSyncAccountService) || instantiationService.stub(IUserDataSyncAccountService, UserDataSyncAccountService), instantiationService.get(ILifecycleService) || instantiationService.stub(ILifecycleService, new TestLifecycleService()), instantiationService.get(INotificationService) || instantiationService.stub(INotificationService, new TestNotificationService()), - instantiationService, + instantiationService.get(IHostService) ); } diff --git a/src/vs/workbench/services/host/browser/browserHostService.ts b/src/vs/workbench/services/host/browser/browserHostService.ts index 0f92adfe6bd7ce0a72c19aace31d9f1674df643c..0c0d094596cea00a4976eb4d64d06654d1a48563 100644 --- a/src/vs/workbench/services/host/browser/browserHostService.ts +++ b/src/vs/workbench/services/host/browser/browserHostService.ts @@ -86,7 +86,6 @@ export class BrowserHostService extends Disposable implements IHostService { constructor( @ILayoutService private readonly layoutService: ILayoutService, - @IEditorService private readonly editorService: IEditorService, @IConfigurationService private readonly configurationService: IConfigurationService, @IFileService private readonly fileService: IFileService, @ILabelService private readonly labelService: ILabelService, @@ -213,88 +212,91 @@ export class BrowserHostService extends Disposable implements IHostService { // Handle Folders to Add if (foldersToAdd.length > 0) { this.instantiationService.invokeFunction(accessor => { - const workspaceEditingService: IWorkspaceEditingService = accessor.get(IWorkspaceEditingService); + const workspaceEditingService: IWorkspaceEditingService = accessor.get(IWorkspaceEditingService); // avoid heavy dependencies (https://github.com/microsoft/vscode/issues/108522) workspaceEditingService.addFolders(foldersToAdd); }); } // Handle Files if (fileOpenables.length > 0) { - - // Support diffMode - if (options?.diffMode && fileOpenables.length === 2) { - const editors = await pathsToEditors(fileOpenables, this.fileService); - if (editors.length !== 2 || !editors[0].resource || !editors[1].resource) { - return; // invalid resources - } - - // Same Window: open via editor service in current window - if (this.shouldReuse(options, true /* file */)) { - this.editorService.openEditor({ - leftResource: editors[0].resource, - rightResource: editors[1].resource - }); - } - - // New Window: open into empty window - else { - const environment = new Map(); - environment.set('diffFileSecondary', editors[0].resource.toString()); - environment.set('diffFilePrimary', editors[1].resource.toString()); - - this.doOpen(undefined, { payload: Array.from(environment.entries()) }); - } - } - - // Just open normally - else { - for (const openable of fileOpenables) { + this.instantiationService.invokeFunction(async accessor => { + const editorService = accessor.get(IEditorService); // avoid heavy dependencies (https://github.com/microsoft/vscode/issues/108522) + + // Support diffMode + if (options?.diffMode && fileOpenables.length === 2) { + const editors = await pathsToEditors(fileOpenables, this.fileService); + if (editors.length !== 2 || !editors[0].resource || !editors[1].resource) { + return; // invalid resources + } // Same Window: open via editor service in current window if (this.shouldReuse(options, true /* file */)) { - let openables: IPathData[] = []; - - // Support: --goto parameter to open on line/col - if (options?.gotoLineMode) { - const pathColumnAware = parseLineAndColumnAware(openable.fileUri.path); - openables = [{ - fileUri: openable.fileUri.with({ path: pathColumnAware.path }), - lineNumber: pathColumnAware.line, - columnNumber: pathColumnAware.column - }]; - } else { - openables = [openable]; - } - - this.editorService.openEditors(await pathsToEditors(openables, this.fileService)); + editorService.openEditor({ + leftResource: editors[0].resource, + rightResource: editors[1].resource + }); } // New Window: open into empty window else { const environment = new Map(); - environment.set('openFile', openable.fileUri.toString()); + environment.set('diffFileSecondary', editors[0].resource.toString()); + environment.set('diffFilePrimary', editors[1].resource.toString()); - if (options?.gotoLineMode) { - environment.set('gotoLineMode', 'true'); + this.doOpen(undefined, { payload: Array.from(environment.entries()) }); + } + } + + // Just open normally + else { + for (const openable of fileOpenables) { + + // Same Window: open via editor service in current window + if (this.shouldReuse(options, true /* file */)) { + let openables: IPathData[] = []; + + // Support: --goto parameter to open on line/col + if (options?.gotoLineMode) { + const pathColumnAware = parseLineAndColumnAware(openable.fileUri.path); + openables = [{ + fileUri: openable.fileUri.with({ path: pathColumnAware.path }), + lineNumber: pathColumnAware.line, + columnNumber: pathColumnAware.column + }]; + } else { + openables = [openable]; + } + + editorService.openEditors(await pathsToEditors(openables, this.fileService)); } - this.doOpen(undefined, { payload: Array.from(environment.entries()) }); + // New Window: open into empty window + else { + const environment = new Map(); + environment.set('openFile', openable.fileUri.toString()); + + if (options?.gotoLineMode) { + environment.set('gotoLineMode', 'true'); + } + + this.doOpen(undefined, { payload: Array.from(environment.entries()) }); + } } } - } - // Support wait mode - const waitMarkerFileURI = options?.waitMarkerFileURI; - if (waitMarkerFileURI) { - (async () => { + // Support wait mode + const waitMarkerFileURI = options?.waitMarkerFileURI; + if (waitMarkerFileURI) { + (async () => { - // Wait for the resources to be closed in the editor... - await this.editorService.whenClosed(fileOpenables.map(openable => ({ resource: openable.fileUri })), { waitForSaved: true }); + // Wait for the resources to be closed in the editor... + await editorService.whenClosed(fileOpenables.map(openable => ({ resource: openable.fileUri })), { waitForSaved: true }); - // ...before deleting the wait marker file - await this.fileService.del(waitMarkerFileURI); - })(); - } + // ...before deleting the wait marker file + await this.fileService.del(waitMarkerFileURI); + })(); + } + }); } }