Skip to content

Commit

Permalink
Merge pull request #469 from CodinGame/wait-workspace-initialization
Browse files Browse the repository at this point in the history
Wait for workspace to be ready
  • Loading branch information
CGNonofr authored Jul 17, 2024
2 parents ce0fdd3 + 751e7a0 commit f40ad22
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/service-override/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BrowserPathServiceOverride extends AbstractPathService {
@IWorkspaceContextService contextService: IWorkspaceContextService
) {
super(
getEnvironmentOverride().userHome ?? guessLocalUserHome(environmentService, contextService),
Promise.resolve(getEnvironmentOverride().userHome ?? guessLocalUserHome(environmentService, contextService)),
remoteAgentService,
environmentService,
contextService
Expand Down
67 changes: 67 additions & 0 deletions vscode-paches/0057-fix-wait-workspace-to-be-ready.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= <[email protected]>
Date: Wed, 17 Jul 2024 11:57:07 +0200
Subject: [PATCH] fix: wait workspace to be ready

---
src/vs/workbench/services/path/browser/pathService.ts | 4 ++--
src/vs/workbench/services/path/common/pathService.ts | 4 ++--
.../workbench/services/path/electron-sandbox/pathService.ts | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/vs/workbench/services/path/browser/pathService.ts b/src/vs/workbench/services/path/browser/pathService.ts
index 2457dbaa576..9f5f8d6aa2b 100644
--- a/src/vs/workbench/services/path/browser/pathService.ts
+++ b/src/vs/workbench/services/path/browser/pathService.ts
@@ -28,14 +28,14 @@ export class BrowserPathService extends AbstractPathService {
}
}

-export function guessLocalUserHome(environmentService: IWorkbenchEnvironmentService, contextService: IWorkspaceContextService): URI {
+export async function guessLocalUserHome(environmentService: IWorkbenchEnvironmentService, contextService: IWorkspaceContextService): Promise<URI> {

// In web we do not really have the concept of a "local" user home
// but we still require it in many places as a fallback. As such,
// we have to come up with a synthetic location derived from the
// environment.

- const workspace = contextService.getWorkspace();
+ const workspace = await contextService.getCompleteWorkspace();

const firstFolder = firstOrDefault(workspace.folders);
if (firstFolder) {
diff --git a/src/vs/workbench/services/path/common/pathService.ts b/src/vs/workbench/services/path/common/pathService.ts
index 83baa4126b0..6a6324c5a1f 100644
--- a/src/vs/workbench/services/path/common/pathService.ts
+++ b/src/vs/workbench/services/path/common/pathService.ts
@@ -88,7 +88,7 @@ export abstract class AbstractPathService implements IPathService {
private maybeUnresolvedUserHome: URI | undefined;

constructor(
- private localUserHome: URI,
+ private localUserHome: Promise<URI>,
@IRemoteAgentService private readonly remoteAgentService: IRemoteAgentService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
@@ -104,7 +104,7 @@ export abstract class AbstractPathService implements IPathService {
// User Home
this.resolveUserHome = (async () => {
const env = await this.remoteAgentService.getEnvironment();
- const userHome = this.maybeUnresolvedUserHome = env?.userHome ?? localUserHome;
+ const userHome = this.maybeUnresolvedUserHome = env?.userHome ?? await localUserHome;

return userHome;
})();
diff --git a/src/vs/workbench/services/path/electron-sandbox/pathService.ts b/src/vs/workbench/services/path/electron-sandbox/pathService.ts
index 7888fc6ab71..9f5e122ca05 100644
--- a/src/vs/workbench/services/path/electron-sandbox/pathService.ts
+++ b/src/vs/workbench/services/path/electron-sandbox/pathService.ts
@@ -16,7 +16,7 @@ export class NativePathService extends AbstractPathService {
@INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IWorkspaceContextService contextService: IWorkspaceContextService
) {
- super(environmentService.userHome, remoteAgentService, environmentService, contextService);
+ super(Promise.resolve(environmentService.userHome), remoteAgentService, environmentService, contextService);
}
}

1 comment on commit f40ad22

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.