diff --git a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts index ef09d88ab1f03..6a3ad8bbf3994 100644 --- a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts +++ b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts @@ -58,9 +58,6 @@ export class HostedPluginSupport { @inject(PluginServer) protected readonly pluginServer: PluginServer; - @inject(WorkspaceService) - protected readonly workspaceService: WorkspaceService; - @inject(PreferenceProviderProvider) protected readonly preferenceProviderProvider: PreferenceProviderProvider; @@ -72,8 +69,9 @@ export class HostedPluginSupport { @inject(PreferenceServiceImpl) private readonly preferenceServiceImpl: PreferenceServiceImpl, @inject(PluginPathsService) private readonly pluginPathsService: PluginPathsService, @inject(StoragePathService) private readonly storagePathService: StoragePathService, + @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService, ) { - this.theiaReadyPromise = Promise.all([this.preferenceServiceImpl.ready]); + this.theiaReadyPromise = Promise.all([this.preferenceServiceImpl.ready, this.workspaceService.roots]); this.storagePathService.onStoragePathChanged(path => { this.updateStoragePath(path); @@ -154,6 +152,7 @@ export class HostedPluginSupport { pluginID = getPluginId(plugins[0].model); } const rpc = this.createServerRpc(pluginID, hostKey); + setUpPluginApi(rpc, container); const hostedExtManager = rpc.getProxy(MAIN_RPC_CONTEXT.HOSTED_PLUGIN_MANAGER_EXT); hostedExtManager.$init({ plugins: plugins, @@ -163,7 +162,6 @@ export class HostedPluginSupport { env: { queryParams: getQueryParameters() }, extApi: initData.pluginAPIs }, confStorage); - setUpPluginApi(rpc, container); this.mainPluginApiProviders.getContributions().forEach(p => p.initialize(rpc, container)); this.backendExtManagerProxy = hostedExtManager; }); diff --git a/packages/plugin-ext/src/main/browser/workspace-main.ts b/packages/plugin-ext/src/main/browser/workspace-main.ts index 76b5d39d62f37..c964ded16bb74 100644 --- a/packages/plugin-ext/src/main/browser/workspace-main.ts +++ b/packages/plugin-ext/src/main/browser/workspace-main.ts @@ -67,10 +67,7 @@ export class WorkspaceMainImpl implements WorkspaceMain { this.inPluginFileSystemWatcherManager = new InPluginFileSystemWatcherManager(this.proxy, container); - this.workspaceService.roots.then(roots => { - this.processWorkspaceFoldersChanged(roots); - }); - + this.processWorkspaceFoldersChanged(this.workspaceService.tryGetRoots()); this.workspaceService.onWorkspaceChanged(roots => { this.processWorkspaceFoldersChanged(roots); }); @@ -81,13 +78,13 @@ export class WorkspaceMainImpl implements WorkspaceMain { return; } this.roots = roots; + this.proxy.$onWorkspaceFoldersChanged({ roots }); await this.storagePathService.updateStoragePath(roots); const keyValueStorageWorkspacesData = await this.pluginServer.keyValueStorageGetAll(false); this.storageProxy.$updatePluginsWorkspaceData(keyValueStorageWorkspacesData); - this.proxy.$onWorkspaceFoldersChanged({ roots }); } private isAnyRootChanged(roots: FileStat[]): boolean {