Skip to content

Commit bad502a

Browse files
Allow Activated Virtual Envs to Be Detected w/ a Workspace File (#25141)
Addresses #25140 (which I just filed). 1) Removed the check that a workspaceFile isn't used when looking for Activate Virtual Envs 2) Adds a debug log to help make other forms of early exit. Of note, I'm not sure if the existing `traceVerbose('VS Code was not launched from the command line');` is correct. As far as I can tell, workspaceFile != multiroot workspaces. I'm not sure why this check previously existed. I don't know if this might cause others problems; but right now this check causes a lot of challenge for our workflow. --------- Co-authored-by: Anthony Kim <[email protected]>
1 parent 58bd7b6 commit bad502a

File tree

2 files changed

+1
-35
lines changed

2 files changed

+1
-35
lines changed

src/client/interpreter/virtualEnvs/activatedEnvLaunch.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,9 @@ export class ActivatedEnvironmentLaunch implements IActivatedEnvironmentLaunch {
8585

8686
@cache(-1, true)
8787
private async _selectIfLaunchedViaActivatedEnv(doNotBlockOnSelection = false): Promise<string | undefined> {
88-
if (this.workspaceService.workspaceFile) {
89-
// Assuming multiroot workspaces cannot be directly launched via `code .` command.
90-
return undefined;
91-
}
9288
if (process.env.VSCODE_CLI !== '1') {
9389
// We only want to select the interpreter if VS Code was launched from the command line.
90+
traceLog("Skipping ActivatedEnv Detection: process.env.VSCODE_CLI !== '1'");
9491
return undefined;
9592
}
9693
traceVerbose('VS Code was not launched from the command line');

src/test/interpreters/virtualEnvs/activatedEnvLaunch.unit.test.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -263,37 +263,6 @@ suite('Activated Env Launch', async () => {
263263
expect(_promptIfApplicable.notCalled).to.equal(true, 'Prompt should not be displayed');
264264
});
265265

266-
test('Does not update interpreter path if a multiroot workspace is opened', async () => {
267-
process.env.VIRTUAL_ENV = virtualEnvPrefix;
268-
interpreterService
269-
.setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny()))
270-
.returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment));
271-
workspaceService.setup((w) => w.workspaceFile).returns(() => uri);
272-
const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 };
273-
workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]);
274-
pythonPathUpdaterService
275-
.setup((p) =>
276-
p.updatePythonPath(
277-
TypeMoq.It.isValue(virtualEnvPrefix),
278-
TypeMoq.It.isValue(ConfigurationTarget.WorkspaceFolder),
279-
TypeMoq.It.isValue('load'),
280-
TypeMoq.It.isValue(uri),
281-
),
282-
)
283-
.returns(() => Promise.resolve())
284-
.verifiable(TypeMoq.Times.never());
285-
activatedEnvLaunch = new ActivatedEnvironmentLaunch(
286-
workspaceService.object,
287-
appShell.object,
288-
pythonPathUpdaterService.object,
289-
interpreterService.object,
290-
processServiceFactory.object,
291-
);
292-
const result = await activatedEnvLaunch.selectIfLaunchedViaActivatedEnv();
293-
expect(result).to.be.equal(undefined, 'Incorrect value');
294-
pythonPathUpdaterService.verifyAll();
295-
});
296-
297266
test('Returns `undefined` if env was already selected', async () => {
298267
activatedEnvLaunch = new ActivatedEnvironmentLaunch(
299268
workspaceService.object,

0 commit comments

Comments
 (0)