From d668876cd55883195affdeaeacf2576b00c7df2b Mon Sep 17 00:00:00 2001 From: Ives van Hoorne Date: Tue, 14 Nov 2023 12:47:09 +0100 Subject: [PATCH] feat: expose `WorkspaceService` We sometimes want to reinitialize the workspace (e.g. when the user decides to change their folders). For this, we need to run: ```ts const workspaceService = accessor.get(IWorkspaceContextService) as WorkspaceService ``` So we can call `initialize` on it. To be able to do this, we need to be able to access the `WorkspaceService` type. In this case I decided to expose it from `configuration.ts`, since it's only used when this service overridden. But let me know if you'd prefer to expose this from services! --- src/service-override/configuration.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/service-override/configuration.ts b/src/service-override/configuration.ts index 37378ece..1431739f 100644 --- a/src/service-override/configuration.ts +++ b/src/service-override/configuration.ts @@ -124,6 +124,11 @@ registerServiceInitializePreParticipant(async (accessor) => { const MemoizedInjectedConfigurationService = memoizedConstructor(InjectedConfigurationService) +export async function reinitializeWorkspace (workspace: IAnyWorkspaceIdentifier): Promise { + const workspaceService = StandaloneServices.get(IWorkspaceContextService) as WorkspaceService + await workspaceService.initialize(workspace) +} + export default function getServiceOverride (defaultWorkspace: URI | IAnyWorkspaceIdentifier): IEditorOverrideServices { _defaultWorkspace = defaultWorkspace