Skip to content
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

If active editor opened is outside the editor, activate the first workspace #22450

Merged
merged 5 commits into from
Nov 10, 2023
Merged
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: 3 additions & 2 deletions src/client/activation/activationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export class ExtensionActivationManager implements IExtensionActivationManager {

@traceDecoratorError('Failed to activate a workspace')
public async activateWorkspace(resource: Resource): Promise<void> {
const folder = this.workspaceService.getWorkspaceFolder(resource);
resource = folder ? folder.uri : undefined;
const key = this.getWorkspaceKey(resource);
if (this.activatedWorkspaces.has(key)) {
return;
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion src/client/interpreter/activation/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
25 changes: 25 additions & 0 deletions src/test/activation/activationManager.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
Loading