@@ -30,10 +30,13 @@ const flatten = require('lodash/flatten') as typeof import('lodash/flatten');
3030 */
3131@injectable ( )
3232export class PythonInterpreterLocatorService implements IInterpreterLocatorService {
33+ public didTriggerInterpreterSuggestions : boolean ;
34+
3335 private readonly disposables : Disposable [ ] = [ ] ;
3436 private readonly platform : IPlatformService ;
3537 private readonly interpreterLocatorHelper : IInterpreterLocatorHelper ;
3638 private readonly _hasInterpreters : Deferred < boolean > ;
39+
3740 constructor (
3841 @inject ( IServiceContainer ) private serviceContainer : IServiceContainer ,
3942 @inject ( InterpreterFilter ) private readonly interpreterFilter : IInterpreterFilter
@@ -42,6 +45,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
4245 serviceContainer . get < Disposable [ ] > ( IDisposableRegistry ) . push ( this ) ;
4346 this . platform = serviceContainer . get < IPlatformService > ( IPlatformService ) ;
4447 this . interpreterLocatorHelper = serviceContainer . get < IInterpreterLocatorHelper > ( IInterpreterLocatorHelper ) ;
48+ this . didTriggerInterpreterSuggestions = false ;
4549 }
4650 /**
4751 * This class should never emit events when we're locating.
@@ -106,18 +110,27 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
106110 // The order is important because the data sources at the bottom of the list do not contain all,
107111 // the information about the interpreters (e.g. type, environment name, etc).
108112 // This way, the items returned from the top of the list will win, when we combine the items returned.
109- const keys : [ string | undefined , OSType | undefined ] [ ] = [
113+ const keys : [ string , OSType | undefined ] [ ] = [
110114 [ WINDOWS_REGISTRY_SERVICE , OSType . Windows ] ,
111115 [ CONDA_ENV_SERVICE , undefined ] ,
112116 [ CONDA_ENV_FILE_SERVICE , undefined ] ,
113- options ?. onActivation ? [ undefined , undefined ] : [ PIPENV_SERVICE , undefined ] ,
117+ [ PIPENV_SERVICE , undefined ] ,
114118 [ GLOBAL_VIRTUAL_ENV_SERVICE , undefined ] ,
115119 [ WORKSPACE_VIRTUAL_ENV_SERVICE , undefined ] ,
116120 [ KNOWN_PATH_SERVICE , undefined ] ,
117121 [ CURRENT_PATH_SERVICE , undefined ]
118122 ] ;
119- return keys
120- . filter ( ( item ) => item [ 0 ] !== undefined && ( item [ 1 ] === undefined || item [ 1 ] === this . platform . osType ) )
123+
124+ const locators = keys
125+ . filter ( ( item ) => item [ 1 ] === undefined || item [ 1 ] === this . platform . osType )
121126 . map ( ( item ) => this . serviceContainer . get < IInterpreterLocatorService > ( IInterpreterLocatorService , item [ 0 ] ) ) ;
127+
128+ // Set it to true the first time the user selects an interpreter
129+ if ( ! this . didTriggerInterpreterSuggestions && options ?. onSuggestion === true ) {
130+ this . didTriggerInterpreterSuggestions = true ;
131+ locators . forEach ( ( locator ) => ( locator . didTriggerInterpreterSuggestions = true ) ) ;
132+ }
133+
134+ return locators ;
122135 }
123136}
0 commit comments