@@ -951,7 +951,7 @@ public IPythonInterpreterFactory GetInterpreterFactory() {
951
951
return service . DefaultInterpreter ;
952
952
}
953
953
954
- var fact = _interpreters . ActiveInterpreter ;
954
+ var fact = interpreters . ActiveInterpreter ;
955
955
956
956
Site . GetPythonToolsService ( ) . EnsureCompletionDb ( fact ) ;
957
957
@@ -969,7 +969,7 @@ public IPythonInterpreterFactory GetInterpreterFactoryOrThrow() {
969
969
return service . DefaultInterpreter ;
970
970
}
971
971
972
- var fact = _interpreters . ActiveInterpreter ;
972
+ var fact = interpreters . ActiveInterpreter ;
973
973
if ( fact == service . NoInterpretersValue ) {
974
974
throw new NoInterpretersException ( ) ;
975
975
}
@@ -1364,12 +1364,19 @@ out IPythonInterpreterFactory factory
1364
1364
if ( args != null && args . TryGetValue ( "e" , out description ) && ! string . IsNullOrEmpty ( description ) ) {
1365
1365
var service = Site . GetComponentModel ( ) . GetService < IInterpreterOptionsService > ( ) ;
1366
1366
1367
- factory = _interpreters . GetInterpreterFactories ( ) . FirstOrDefault (
1368
- // Description is a localized string, hence CCIC
1369
- f => description . Equals ( f . Description , StringComparison . CurrentCultureIgnoreCase )
1370
- ) ?? service . Interpreters . FirstOrDefault (
1371
- f => description . Equals ( f . Description , StringComparison . CurrentCultureIgnoreCase )
1372
- ) ;
1367
+ var interpreters = _interpreters ;
1368
+ if ( interpreters != null ) {
1369
+ factory = interpreters . GetInterpreterFactories ( ) . FirstOrDefault (
1370
+ // Description is a localized string, hence CCIC
1371
+ f => description . Equals ( f . Description , StringComparison . CurrentCultureIgnoreCase )
1372
+ ) ;
1373
+ }
1374
+
1375
+ if ( factory == null ) {
1376
+ factory = service . Interpreters . FirstOrDefault (
1377
+ f => description . Equals ( f . Description , StringComparison . CurrentCultureIgnoreCase )
1378
+ ) ;
1379
+ }
1373
1380
}
1374
1381
1375
1382
if ( factory == null ) {
@@ -2059,7 +2066,12 @@ private void ShowAddInterpreter() {
2059
2066
return ;
2060
2067
}
2061
2068
2062
- var toRemove = new HashSet < IPythonInterpreterFactory > ( _interpreters . GetInterpreterFactories ( ) ) ;
2069
+ var interpreters = _interpreters ;
2070
+ if ( interpreters == null ) {
2071
+ return ;
2072
+ }
2073
+
2074
+ var toRemove = new HashSet < IPythonInterpreterFactory > ( interpreters . GetInterpreterFactories ( ) ) ;
2063
2075
var toAdd = new HashSet < IPythonInterpreterFactory > ( result ) ;
2064
2076
toRemove . ExceptWith ( toAdd ) ;
2065
2077
toAdd . ExceptWith ( toRemove ) ;
@@ -2070,10 +2082,10 @@ private void ShowAddInterpreter() {
2070
2082
throw Marshal . GetExceptionForHR ( VSConstants . OLE_E_PROMPTSAVECANCELLED ) ;
2071
2083
}
2072
2084
foreach ( var factory in toAdd ) {
2073
- _interpreters . AddInterpreter ( factory ) ;
2085
+ interpreters . AddInterpreter ( factory ) ;
2074
2086
}
2075
2087
foreach ( var factory in toRemove ) {
2076
- _interpreters . RemoveInterpreterFactory ( factory ) ;
2088
+ interpreters . RemoveInterpreterFactory ( factory ) ;
2077
2089
}
2078
2090
}
2079
2091
}
@@ -2127,7 +2139,12 @@ await VirtualEnv.CreateAndInstallDependencies(
2127
2139
) ;
2128
2140
}
2129
2141
2130
- var existing = _interpreters . FindInterpreter ( path ) ;
2142
+ var interpreters = _interpreters ;
2143
+ if ( interpreters == null ) {
2144
+ return null ;
2145
+ }
2146
+
2147
+ var existing = interpreters . FindInterpreter ( path ) ;
2131
2148
if ( existing != null ) {
2132
2149
return existing ;
2133
2150
}
@@ -2144,8 +2161,8 @@ await VirtualEnv.CreateAndInstallDependencies(
2144
2161
throw Marshal . GetExceptionForHR ( VSConstants . OLE_E_PROMPTSAVECANCELLED ) ;
2145
2162
}
2146
2163
2147
- var id = _interpreters . CreateInterpreterFactory ( options ) ;
2148
- return _interpreters . FindInterpreter ( id , options . LanguageVersion ) ;
2164
+ var id = interpreters . CreateInterpreterFactory ( options ) ;
2165
+ return interpreters . FindInterpreter ( id , options . LanguageVersion ) ;
2149
2166
}
2150
2167
2151
2168
0 commit comments