Skip to content

Commit 512271a

Browse files
author
Loïc Mangeonjean
committed
fix: split initialization file to initialize in correct order
1 parent 3984356 commit 512271a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/service-override/configuration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import 'vs/workbench/api/common/configurationExtensionPoint'
3535
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService'
3636
import getFileServiceOverride from './files'
3737
import { memoizedConstructor, unsupported } from '../tools'
38-
import { registerServiceInitializeParticipant } from '../services'
38+
import { registerServiceInitializePreParticipant } from '../services'
3939

4040
async function updateUserConfiguration (configurationJson: string): Promise<void> {
4141
const userDataProfilesService = StandaloneServices.get(IUserDataProfilesService)
@@ -79,7 +79,7 @@ class MonacoWorkspaceEditingService extends AbstractWorkspaceEditingService {
7979
}
8080

8181
let _defaultWorkspaceUri = URI.file('/workspace')
82-
registerServiceInitializeParticipant(async (accessor) => {
82+
registerServiceInitializePreParticipant(async (accessor) => {
8383
const workspaceService = accessor.get(IWorkspaceContextService) as WorkspaceService
8484
workspaceService.acquireInstantiationService(accessor.get(IInstantiationService))
8585

src/services.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ import getFileServiceOverride from './service-override/files'
1919
interface ServiceInitializeParticipant {
2020
(accessor: ServicesAccessor): Promise<void>
2121
}
22+
const serviceInitializePreParticipants: ServiceInitializeParticipant[] = []
2223
const serviceInitializeParticipants: ServiceInitializeParticipant[] = []
24+
const serviceInitializePostParticipants: ServiceInitializeParticipant[] = []
25+
export function registerServiceInitializePreParticipant (participant: ServiceInitializeParticipant): void {
26+
serviceInitializePreParticipants.push(participant)
27+
}
2328
export function registerServiceInitializeParticipant (participant: ServiceInitializeParticipant): void {
2429
serviceInitializeParticipants.push(participant)
2530
}
31+
export function registerServiceInitializePostParticipant (participant: ServiceInitializeParticipant): void {
32+
serviceInitializePostParticipants.push(participant)
33+
}
2634

2735
async function initServices (overrides: IEditorOverrideServices): Promise<IInstantiationService> {
2836
const instantiationService = StandaloneServices.initialize({
@@ -33,6 +41,10 @@ async function initServices (overrides: IEditorOverrideServices): Promise<IInsta
3341
...overrides
3442
})
3543

44+
await instantiationService.invokeFunction(async accessor => {
45+
await Promise.all(serviceInitializePreParticipants.map(participant => participant(accessor)))
46+
})
47+
3648
await instantiationService.invokeFunction(async accessor => {
3749
const lifecycleService = accessor.get(ILifecycleService)
3850

@@ -42,6 +54,10 @@ async function initServices (overrides: IEditorOverrideServices): Promise<IInsta
4254
lifecycleService.phase = LifecyclePhase.Ready
4355
})
4456

57+
await instantiationService.invokeFunction(async accessor => {
58+
await Promise.all(serviceInitializePostParticipants.map(participant => participant(accessor)))
59+
})
60+
4561
return instantiationService
4662
}
4763

0 commit comments

Comments
 (0)