File tree 2 files changed +26
-18
lines changed
src/client/pythonEnvironments/base
2 files changed +26
-18
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT License.
3
3
4
- import { EMPTY_VERSION , parseBasicVersionInfo } from '../../../../client/ common/utils/version' ;
4
+ import { EMPTY_VERSION , parseBasicVersionInfo } from '../../../common/utils/version' ;
5
5
6
6
import { PythonReleaseLevel , PythonVersion } from '.' ;
7
7
Original file line number Diff line number Diff line change @@ -30,28 +30,36 @@ export function getQueryFilter(query: PythonLocatorQuery): (env: PythonEnvInfo)
30
30
} ) ) ;
31
31
}
32
32
}
33
- return ( env ) => {
34
- if ( kinds !== undefined ) {
35
- if ( ! kinds . includes ( env . kind ) ) {
36
- return false ;
37
- }
33
+ function checkKind ( env : PythonEnvInfo ) : boolean {
34
+ if ( kinds === undefined ) {
35
+ return true ;
38
36
}
37
+ return kinds . includes ( env . kind ) ;
38
+ }
39
+ function checkSearchLocation ( env : PythonEnvInfo ) : boolean {
39
40
if ( env . searchLocation === undefined ) {
40
- if ( ! includeGlobal ) {
41
- return false ;
42
- }
43
- } else if ( locationFilters === undefined ) {
41
+ // It is not a "rooted" env.
42
+ return includeGlobal ;
43
+ }
44
+
45
+ // It is a "rooted" env.
46
+ if ( locationFilters === undefined ) {
44
47
if ( query . searchLocations === null ) {
48
+ // The caller explicitly refused rooted envs.
45
49
return false ;
46
50
}
47
- if ( query . searchLocations && query . searchLocations . length > 0 ) {
48
- // Only envs without searchLocation set were requested?
49
- return false ;
50
- }
51
- } else {
52
- if ( ! locationFilters . some ( ( filter ) => filter ( env . searchLocation ! ) ) ) {
53
- return false ;
54
- }
51
+ // `query.searchLocations` only had `null` in it.
52
+ return ! query . searchLocations || query . searchLocations . length === 0 ;
53
+ }
54
+ // Check against the requested roots.
55
+ return locationFilters . some ( ( filter ) => filter ( env . searchLocation ! ) ) ;
56
+ }
57
+ return ( env ) => {
58
+ if ( ! checkKind ( env ) ) {
59
+ return false ;
60
+ }
61
+ if ( ! checkSearchLocation ( env ) ) {
62
+ return false ;
55
63
}
56
64
return true ;
57
65
} ;
You can’t perform that action at this time.
0 commit comments