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
12 changes: 8 additions & 4 deletions src/client/interpreter/interpreterService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class InterpreterService implements Disposable, IInterpreterService {
environments
.filter((item) => !item.displayName)
.map(async (item) => {
item.displayName = await this.getDisplayName(item, resource);
item.displayName = await this.getDisplayName(item, resource, options?.ignoreCache);
// Keep information up to date with latest details.
if (!item.cachedEntry) {
this.updateCachedInterpreterInformation(item, resource).ignoreErrors();
Expand Down Expand Up @@ -277,9 +277,13 @@ export class InterpreterService implements Disposable, IInterpreterService {
* @returns {string}
* @memberof InterpreterService
*/
public async getDisplayName(info: Partial<PythonEnvironment>, resource?: Uri): Promise<string> {
public async getDisplayName(
info: Partial<PythonEnvironment>,
resource?: Uri,
ignoreCache = false,
): Promise<string> {
// faster than calculating file has again and again, only when dealing with cached items.
if (!info.cachedEntry && info.path && this.inMemoryCacheOfDisplayNames.has(info.path)) {
if (!ignoreCache && !info.cachedEntry && info.path && this.inMemoryCacheOfDisplayNames.has(info.path)) {
return this.inMemoryCacheOfDisplayNames.get(info.path)!;
}
const interpreterKey = info.path ?? '';
Expand All @@ -289,7 +293,7 @@ export class InterpreterService implements Disposable, IInterpreterService {
EXPIRY_DURATION,
);

if (store.value && store.value.hash === interpreterKey && store.value.displayName) {
if (!ignoreCache && store.value && store.value.hash === interpreterKey && store.value.displayName) {
this.inMemoryCacheOfDisplayNames.set(info.path!, store.value.displayName);
return store.value.displayName;
}
Expand Down
1 change: 1 addition & 0 deletions src/client/pythonEnvironments/legacyIOC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class ComponentAdapter implements IComponentAdapter, IExtensionSingleActivationS
const query = {
kinds: e.kind ? [e.kind] : undefined,
searchLocations: e.searchLocation ? { roots: [e.searchLocation] } : undefined,
ignoreCache: true,
};
// Trigger a background refresh of the environments.
getEnvs(this.api.iterEnvs(query)).ignoreErrors();
Expand Down
1 change: 1 addition & 0 deletions src/test/interpreters/interpreterService.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ suite('Interpreters service', () => {
const displayName = await service.getDisplayName(
interpreterInfo,
resource,
true,
);
expect(displayName).to.equal(expectedDisplayName);
});
Expand Down