diff --git a/src/client/activation/activationManager.ts b/src/client/activation/activationManager.ts index fac5cbeda648..763ce1ae8819 100644 --- a/src/client/activation/activationManager.ts +++ b/src/client/activation/activationManager.ts @@ -83,6 +83,8 @@ export class ExtensionActivationManager implements IExtensionActivationManager { @traceDecoratorError('Failed to activate a workspace') public async activateWorkspace(resource: Resource): Promise { + const folder = this.workspaceService.getWorkspaceFolder(resource); + resource = folder ? folder.uri : undefined; const key = this.getWorkspaceKey(resource); if (this.activatedWorkspaces.has(key)) { return; @@ -117,8 +119,7 @@ export class ExtensionActivationManager implements IExtensionActivationManager { if (this.activatedWorkspaces.has(key)) { return; } - const folder = this.workspaceService.getWorkspaceFolder(doc.uri); - this.activateWorkspace(folder ? folder.uri : undefined).ignoreErrors(); + this.activateWorkspace(doc.uri).ignoreErrors(); } protected addHandlers(): void { diff --git a/src/client/interpreter/activation/service.ts b/src/client/interpreter/activation/service.ts index f97545a5823a..4eac5ad94d30 100644 --- a/src/client/interpreter/activation/service.ts +++ b/src/client/interpreter/activation/service.ts @@ -259,7 +259,9 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi shellInfo.shellType, interpreter, ); - traceVerbose(`Activation Commands received ${activationCommands} for shell ${shellInfo.shell}`); + traceVerbose( + `Activation Commands received ${activationCommands} for shell ${shellInfo.shell}, resource ${resource?.fsPath} and interpreter ${interpreter?.path}`, + ); if (!activationCommands || !Array.isArray(activationCommands) || activationCommands.length === 0) { if (interpreter && [EnvironmentType.Venv, EnvironmentType.Pyenv].includes(interpreter?.envType)) { const key = getSearchPathEnvVarNames()[0]; diff --git a/src/test/activation/activationManager.unit.test.ts b/src/test/activation/activationManager.unit.test.ts index 2b8d54f12ee9..6ee2572214b8 100644 --- a/src/test/activation/activationManager.unit.test.ts +++ b/src/test/activation/activationManager.unit.test.ts @@ -82,6 +82,12 @@ suite('Activation Manager', () => { test('If running in a virtual workspace, do not activate services that do not support it', async () => { when(workspaceService.isVirtualWorkspace).thenReturn(true); const resource = Uri.parse('two'); + const workspaceFolder = { + index: 0, + name: 'one', + uri: resource, + }; + when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); autoSelection .setup((a) => a.autoSelectInterpreter(resource)) @@ -112,6 +118,12 @@ suite('Activation Manager', () => { test('If running in a untrusted workspace, do not activate services that do not support it', async () => { when(workspaceService.isTrusted).thenReturn(false); const resource = Uri.parse('two'); + const workspaceFolder = { + index: 0, + name: 'one', + uri: resource, + }; + when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); autoSelection .setup((a) => a.autoSelectInterpreter(resource)) @@ -150,6 +162,13 @@ suite('Activation Manager', () => { .returns(() => Promise.resolve()) .verifiable(typemoq.Times.once()); + const workspaceFolder = { + index: 0, + name: 'one', + uri: resource, + }; + when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); + await managerTest.activateWorkspace(resource); autoSelection.verifyAll(); @@ -289,6 +308,12 @@ suite('Activation Manager', () => { .setup((a) => a.performPreStartupHealthCheck(resource)) .returns(() => Promise.resolve()) .verifiable(typemoq.Times.once()); + const workspaceFolder = { + index: 0, + name: 'one', + uri: resource, + }; + when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); await managerTest.activateWorkspace(resource); await managerTest.activateWorkspace(resource);