Skip to content

Commit

Permalink
fix: initialize configuration/storage/files/remoteAgent BEFORE instan…
Browse files Browse the repository at this point in the history
…tiating HostService

as in the workbench, because the HostService depends on a log of other services that needs the workspace to be initialized (like the PathService)
  • Loading branch information
Loïc Mangeonjean committed Jul 17, 2024
1 parent d48bb57 commit 920f19c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/service-override/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/c
import { IHostService } from 'vs/workbench/services/host/browser/host.service'
import { ExtensionStorageService } from 'vs/platform/extensionManagement/common/extensionStorage'
import { IExtensionStorageService } from 'vs/platform/extensionManagement/common/extensionStorage.service'
import { registerServiceInitializePreParticipant } from '../lifecycle'
import { registerServiceInitializeParticipant, registerServiceInitializePreParticipant } from '../lifecycle'
import { getWorkspaceIdentifier } from '../workbench'

export enum StorageScope {
Expand Down Expand Up @@ -159,18 +159,21 @@ class ExternalStorageService extends AbstractStorageService {

registerServiceInitializePreParticipant(async (accessor) => {
const storageService = accessor.get(IStorageService)
const hostService = accessor.get(IHostService)
if (storageService instanceof AbstractStorageService) {
await storageService.initialize()

hostService.onDidChangeFocus(focus => {
if (!focus) {
void storageService.flush()
}
})
}
})

registerServiceInitializeParticipant(async (accessor) => {
const hostService = accessor.get(IHostService)
const storageService = accessor.get(IStorageService)
hostService.onDidChangeFocus(focus => {
if (!focus) {
void storageService.flush()
}
})
})

class InjectedBrowserStorageService extends BrowserStorageService {
constructor (
private fallbackOverride: Record<string, unknown> | undefined,
Expand Down

0 comments on commit 920f19c

Please sign in to comment.