From 751e7a052acafbc79db284a25803d252991dde55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Wed, 17 Jul 2024 12:19:05 +0200 Subject: [PATCH] fix: wait for workspace to be ready In VSCode, this is not a problem because the ConfigurationService is initialized before other services are even instantiated, but that's not possible here --- src/service-override/base.ts | 2 +- .../0057-fix-wait-workspace-to-be-ready.patch | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 vscode-paches/0057-fix-wait-workspace-to-be-ready.patch diff --git a/src/service-override/base.ts b/src/service-override/base.ts index 811cec64..58a423b3 100644 --- a/src/service-override/base.ts +++ b/src/service-override/base.ts @@ -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 diff --git a/vscode-paches/0057-fix-wait-workspace-to-be-ready.patch b/vscode-paches/0057-fix-wait-workspace-to-be-ready.patch new file mode 100644 index 00000000..9d75db93 --- /dev/null +++ b/vscode-paches/0057-fix-wait-workspace-to-be-ready.patch @@ -0,0 +1,67 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= +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 { + + // 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, + @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); + } + } +