Skip to content

Allow Activated Virtual Envs to Be Detected w/ a Workspace File #25141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/client/interpreter/virtualEnvs/activatedEnvLaunch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,9 @@ export class ActivatedEnvironmentLaunch implements IActivatedEnvironmentLaunch {

@cache(-1, true)
private async _selectIfLaunchedViaActivatedEnv(doNotBlockOnSelection = false): Promise<string | undefined> {
if (this.workspaceService.workspaceFile) {
// Assuming multiroot workspaces cannot be directly launched via `code .` command.
return undefined;
}
if (process.env.VSCODE_CLI !== '1') {
// We only want to select the interpreter if VS Code was launched from the command line.
traceLog("Skipping ActivatedEnv Detection: process.env.VSCODE_CLI !== '1'");
return undefined;
}
traceVerbose('VS Code was not launched from the command line');
Expand Down
31 changes: 0 additions & 31 deletions src/test/interpreters/virtualEnvs/activatedEnvLaunch.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,37 +263,6 @@ suite('Activated Env Launch', async () => {
expect(_promptIfApplicable.notCalled).to.equal(true, 'Prompt should not be displayed');
});

test('Does not update interpreter path if a multiroot workspace is opened', async () => {
process.env.VIRTUAL_ENV = virtualEnvPrefix;
interpreterService
.setup((i) => i.getInterpreterDetails(TypeMoq.It.isAny()))
.returns(() => Promise.resolve(({ envName: 'base' } as unknown) as PythonEnvironment));
workspaceService.setup((w) => w.workspaceFile).returns(() => uri);
const workspaceFolder: WorkspaceFolder = { name: 'one', uri, index: 0 };
workspaceService.setup((w) => w.workspaceFolders).returns(() => [workspaceFolder]);
pythonPathUpdaterService
.setup((p) =>
p.updatePythonPath(
TypeMoq.It.isValue(virtualEnvPrefix),
TypeMoq.It.isValue(ConfigurationTarget.WorkspaceFolder),
TypeMoq.It.isValue('load'),
TypeMoq.It.isValue(uri),
),
)
.returns(() => Promise.resolve())
.verifiable(TypeMoq.Times.never());
activatedEnvLaunch = new ActivatedEnvironmentLaunch(
workspaceService.object,
appShell.object,
pythonPathUpdaterService.object,
interpreterService.object,
processServiceFactory.object,
);
const result = await activatedEnvLaunch.selectIfLaunchedViaActivatedEnv();
expect(result).to.be.equal(undefined, 'Incorrect value');
pythonPathUpdaterService.verifyAll();
});

test('Returns `undefined` if env was already selected', async () => {
activatedEnvLaunch = new ActivatedEnvironmentLaunch(
workspaceService.object,
Expand Down