Skip to content

Commit

Permalink
Trigger discovery if environment cache is empty (microsoft/vscode-pyt…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj authored and wesm committed Mar 28, 2024
1 parent b7a4321 commit 06c2f61
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions extensions/positron-python/src/client/pythonEnvironments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,20 @@ export async function activate(api: IDiscoveryAPI, ext: ExtensionState): Promise
* extension activation on the "refresh trigger".
*/
const folders = vscode.workspace.workspaceFolders;
const wasTriggered = getGlobalStorage<boolean>(ext.context, 'PYTHON_WAS_DISCOVERY_TRIGGERED', false);
if (!wasTriggered.get()) {
// Trigger discovery if environment cache is empty.
const wasTriggered = getGlobalStorage<PythonEnvInfo[]>(ext.context, 'PYTHON_ENV_INFO_CACHE', []).get().length > 0;
if (!wasTriggered) {
api.triggerRefresh().ignoreErrors();
wasTriggered.set(true).then(() => {
folders?.forEach(async (folder) => {
const wasTriggeredForFolder = getGlobalStorage<boolean>(
ext.context,
`PYTHON_WAS_DISCOVERY_TRIGGERED_${normCasePath(folder.uri.fsPath)}`,
false,
);
await wasTriggeredForFolder.set(true);
});
folders?.forEach(async (folder) => {
const wasTriggeredForFolder = getGlobalStorage<boolean>(
ext.context,
`PYTHON_WAS_DISCOVERY_TRIGGERED_${normCasePath(folder.uri.fsPath)}`,
false,
);
await wasTriggeredForFolder.set(true);
});
} else {
// Figure out which workspace folders need to be activated.
// Figure out which workspace folders need to be activated if any.
folders?.forEach(async (folder) => {
const wasTriggeredForFolder = getGlobalStorage<boolean>(
ext.context,
Expand Down

0 comments on commit 06c2f61

Please sign in to comment.