Skip to content
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
1 change: 1 addition & 0 deletions src/client/pythonEnvironments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function initialize(ext: ExtensionState): PythonEnvironments {
ext.legacyIOC.serviceManager,
api,
environmentsSecurity,
ext.disposables
);

return api;
Expand Down
13 changes: 12 additions & 1 deletion src/client/pythonEnvironments/legacyIOC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { injectable } from 'inversify';
import * as vscode from 'vscode';
import { IExtensionSingleActivationService } from '../activation/types';
import { DiscoveryVariants } from '../common/experiments/groups';
import { IDisposableRegistry } from '../common/types';
import { getVersionString, parseVersion } from '../common/utils/version';
import {
CONDA_ENV_FILE_SERVICE,
Expand Down Expand Up @@ -152,6 +153,7 @@ class ComponentAdapter implements IComponentAdapter, IExtensionSingleActivationS
// The adapter only wraps one thing: the component API.
private readonly api: IPythonEnvironments,
private readonly environmentsSecurity: IEnvironmentsSecurity,
private readonly disposables: IDisposableRegistry,
) {}

public async activate(): Promise<void> {
Expand All @@ -161,6 +163,14 @@ class ComponentAdapter implements IComponentAdapter, IExtensionSingleActivationS
inExperiment(DiscoveryVariants.discoveryWithoutFileWatching),
],
)).includes(true);
this.disposables.push(this.api.onChanged((e) => {
const query = {
kinds: e.kind ? [e.kind] : undefined,
searchLocations: e.searchLocation ? { roots: [e.searchLocation] } : undefined
};
// Trigger a background refresh of the environments.
getEnvs(this.api.iterEnvs(query)).ignoreErrors();
}));
}

// IInterpreterLocatorProgressHandler
Expand Down Expand Up @@ -409,10 +419,11 @@ export function registerNewDiscoveryForIOC(
serviceManager: IServiceManager,
api: IPythonEnvironments,
environmentsSecurity: EnvironmentsSecurity,
disposables: IDisposableRegistry
): void {
serviceManager.addSingletonInstance<IComponentAdapter>(
IComponentAdapter,
new ComponentAdapter(api, environmentsSecurity),
new ComponentAdapter(api, environmentsSecurity, disposables),
);
serviceManager.addBinding(IComponentAdapter, IExtensionSingleActivationService);
}
1 change: 1 addition & 0 deletions src/test/pythonEnvironments/legacyIOC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ export function registerForIOC(
serviceManager,
instance(mock(PythonEnvironments)),
instance(mock(EnvironmentsSecurity)),
[]
);
}