@@ -103,32 +103,44 @@ export type AutoActivationType = 'off' | 'command' | 'shellStartup';
103103 * - 'off': Auto-activation is disabled
104104 *
105105 * Priority order:
106- * 1. python-envs.terminal.autoActivationType setting
107- * 2. python.terminal.activateEnvironment setting (if false updates python-envs.terminal.autoActivationType)
106+ * 1. python-envs.terminal.autoActivationType
107+ * a. globalRemoteValue
108+ * b. globalLocalValue
109+ * c. globalValue
110+ * 2. python.terminal.activateEnvironment setting (if false, returns 'off' & sets autoActivationType to 'off')
108111 * 3. Default to 'command' if no setting is found
109112 *
110113 * @returns {AutoActivationType } The determined auto-activation type
111114 */
112115export function getAutoActivationType ( ) : AutoActivationType {
113116 const pyEnvsConfig = getConfiguration ( 'python-envs' ) ;
117+ const pyEnvsActivationType = pyEnvsConfig . inspect < AutoActivationType > ( 'terminal.autoActivationType' ) ;
114118
115- const pyEnvsActivationType = pyEnvsConfig . get < AutoActivationType | undefined > (
116- 'terminal.autoActivationType' ,
117- undefined ,
118- ) ;
119- if ( pyEnvsActivationType !== undefined ) {
120- return pyEnvsActivationType ;
119+ if ( pyEnvsActivationType ) {
120+ // Priority order: globalRemoteValue > globalLocalValue > globalValue
121+ const activationType = pyEnvsActivationType as Record < string , unknown > ;
122+
123+ if ( 'globalRemoteValue' in pyEnvsActivationType && activationType . globalRemoteValue !== undefined ) {
124+ return activationType . globalRemoteValue as AutoActivationType ;
125+ }
126+ if ( 'globalLocalValue' in pyEnvsActivationType && activationType . globalLocalValue !== undefined ) {
127+ return activationType . globalLocalValue as AutoActivationType ;
128+ }
129+ if ( pyEnvsActivationType . globalValue !== undefined ) {
130+ return pyEnvsActivationType . globalValue ;
131+ }
121132 }
122133
134+ // If none of the python-envs settings are defined, check the legacy python setting
123135 const pythonConfig = getConfiguration ( 'python' ) ;
124136 const pythonActivateSetting = pythonConfig . get < boolean | undefined > ( 'terminal.activateEnvironment' , undefined ) ;
125- if ( pythonActivateSetting !== undefined ) {
126- if ( pythonActivateSetting === false ) {
127- pyEnvsConfig . set ( 'terminal.autoActivationType' , ACT_TYPE_OFF ) ;
128- }
129- return pythonActivateSetting ? ACT_TYPE_COMMAND : ACT_TYPE_OFF ;
137+ if ( pythonActivateSetting === false ) {
138+ // Set autoActivationType to 'off' if python.terminal.activateEnvironment is false
139+ pyEnvsConfig . update ( 'terminal.autoActivationType' , ACT_TYPE_OFF ) ;
140+ return ACT_TYPE_OFF ;
130141 }
131142
143+ // Default to 'command' if no settings are found or if pythonActivateSetting is true/undefined
132144 return ACT_TYPE_COMMAND ;
133145}
134146
0 commit comments