Skip to content

Commit

Permalink
feat: expose WorkspaceService
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
CompuIves committed Nov 14, 2023
1 parent aff4f2f commit d668876
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/service-override/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ registerServiceInitializePreParticipant(async (accessor) => {

const MemoizedInjectedConfigurationService = memoizedConstructor(InjectedConfigurationService)

export async function reinitializeWorkspace (workspace: IAnyWorkspaceIdentifier): Promise<void> {
const workspaceService = StandaloneServices.get(IWorkspaceContextService) as WorkspaceService
await workspaceService.initialize(workspace)
}

export default function getServiceOverride (defaultWorkspace: URI | IAnyWorkspaceIdentifier): IEditorOverrideServices {
_defaultWorkspace = defaultWorkspace

Expand Down

0 comments on commit d668876

Please sign in to comment.