Skip to content

Commit

Permalink
Ensure we trigger discovery for the first time as part of extension a…
Browse files Browse the repository at this point in the history
…ctivation (microsoft#17304)

* Ensure we trigger discovery for the first time as part of extension activation

* Oops
  • Loading branch information
Kartik Raj committed Sep 7, 2021
1 parent db12c6a commit 749a50d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/17303.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure we trigger discovery for the first time as part of extension activation.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection

public getEnvs(query?: PythonLocatorQuery): PythonEnvInfo[] {
const cachedEnvs = this.cache.getAllEnvs();
if (cachedEnvs.length === 0) {
this.triggerRefresh().ignoreErrors();
}
return query ? cachedEnvs.filter(getQueryFilter(query)) : cachedEnvs;
}

Expand Down
7 changes: 2 additions & 5 deletions src/client/pythonEnvironments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
IEnvsCollectionCache,
} from './base/locators/composite/envsCollectionCache';
import { EnvsCollectionService } from './base/locators/composite/envsCollectionService';
import { addItemsToRunAfterActivation } from '../common/utils/runAfterActivation';

/**
* Set up the Python environments component (during extension activation).'
Expand Down Expand Up @@ -62,10 +61,8 @@ export async function activate(api: IDiscoveryAPI): Promise<ActivationResult> {
};
}

addItemsToRunAfterActivation(() => {
// Force an initial background refresh of the environments.
api.triggerRefresh().ignoreErrors();
});
// Force an initial background refresh of the environments.
api.triggerRefresh().ignoreErrors();

return {
fullyReady: Promise.resolve(),
Expand Down

0 comments on commit 749a50d

Please sign in to comment.