@@ -12,10 +12,7 @@ import { PythonEnvsReducer } from './base/locators/composite/envsReducer';
12
12
import { PythonEnvsResolver } from './base/locators/composite/envsResolver' ;
13
13
import { WindowsPathEnvVarLocator } from './base/locators/lowLevel/windowsKnownPathsLocator' ;
14
14
import { WorkspaceVirtualEnvironmentLocator } from './base/locators/lowLevel/workspaceVirtualEnvLocator' ;
15
- import {
16
- initializeExternalDependencies as initializeLegacyExternalDependencies ,
17
- normCasePath ,
18
- } from './common/externalDependencies' ;
15
+ import { initializeExternalDependencies as initializeLegacyExternalDependencies } from './common/externalDependencies' ;
19
16
import { ExtensionLocators , WatchRootsArgs , WorkspaceLocators } from './base/locators/wrappers' ;
20
17
import { CustomVirtualEnvironmentLocator } from './base/locators/lowLevel/customVirtualEnvLocator' ;
21
18
import { CondaEnvironmentLocator } from './base/locators/lowLevel/condaLocator' ;
@@ -55,44 +52,20 @@ export async function initialize(ext: ExtensionState): Promise<IDiscoveryAPI> {
55
52
/**
56
53
* Make use of the component (e.g. register with VS Code).
57
54
*/
58
- export async function activate ( api : IDiscoveryAPI , ext : ExtensionState ) : Promise < ActivationResult > {
55
+ export async function activate ( api : IDiscoveryAPI , _ext : ExtensionState ) : Promise < ActivationResult > {
59
56
/**
60
57
* Force an initial background refresh of the environments.
61
58
*
62
- * Note API is ready to be queried only after a refresh has been triggered, and extension activation is
63
- * blocked on API being ready. So if discovery was never triggered for a scope, we need to block
64
- * extension activation on the "refresh trigger".
59
+ * Note API is ready to be queried only after a refresh has been triggered, and extension activation is blocked on API. So,
60
+ * * If discovery was never triggered, we need to block extension activation on the refresh trigger.
61
+ * * If discovery was already triggered, it maybe the case that this is a new workspace for which it hasn't been triggered yet.
62
+ * So always trigger discovery as part of extension activation for now.
63
+ *
64
+ * TODO: https://github.com/microsoft/vscode-python/issues/17498
65
+ * Once `onInterpretersChanged` event is exposed via API, we can probably expect extensions to rely on that and
66
+ * discovery can be triggered after activation, especially in the second case.
65
67
*/
66
- const folders = vscode . workspace . workspaceFolders ;
67
- const wasTriggered = getGlobalStorage < boolean > ( ext . context , 'PYTHON_WAS_DISCOVERY_TRIGGERED' , false ) ;
68
- if ( ! wasTriggered . get ( ) ) {
69
- api . triggerRefresh ( ) . ignoreErrors ( ) ;
70
- wasTriggered . set ( true ) . then ( ( ) => {
71
- folders ?. forEach ( async ( folder ) => {
72
- const wasTriggeredForFolder = getGlobalStorage < boolean > (
73
- ext . context ,
74
- `PYTHON_WAS_DISCOVERY_TRIGGERED_${ normCasePath ( folder . uri . fsPath ) } ` ,
75
- false ,
76
- ) ;
77
- await wasTriggeredForFolder . set ( true ) ;
78
- } ) ;
79
- } ) ;
80
- } else {
81
- // Figure out which workspace folders need to be activated.
82
- folders ?. forEach ( async ( folder ) => {
83
- const wasTriggeredForFolder = getGlobalStorage < boolean > (
84
- ext . context ,
85
- `PYTHON_WAS_DISCOVERY_TRIGGERED_${ normCasePath ( folder . uri . fsPath ) } ` ,
86
- false ,
87
- ) ;
88
- if ( ! wasTriggeredForFolder . get ( ) ) {
89
- api . triggerRefresh ( {
90
- searchLocations : { roots : [ folder . uri ] , doNotIncludeNonRooted : true } ,
91
- } ) . ignoreErrors ( ) ;
92
- await wasTriggeredForFolder . set ( true ) ;
93
- }
94
- } ) ;
95
- }
68
+ api . triggerRefresh ( ) . ignoreErrors ( ) ;
96
69
97
70
return {
98
71
fullyReady : Promise . resolve ( ) ,
0 commit comments