@@ -19,39 +19,35 @@ export function getCallingExtension(): string {
19
19
const pythonExts = [ ENVS_EXTENSION_ID , PYTHON_EXTENSION_ID ] ;
20
20
21
21
const extensions = allExtensions ( ) ;
22
- const otherExts = extensions . map ( ( ext ) => ext . id ) . filter ( ( id ) => ! pythonExts . includes ( id ) ) ;
23
- const frames = getFrameData ( ) ;
22
+ const otherExts = extensions . filter ( ( ext ) => ! pythonExts . includes ( ext . id ) ) ;
23
+ const frames = getFrameData ( ) . filter ( ( frame ) => ! ! frame . filePath ) ;
24
24
25
25
for ( const frame of frames ) {
26
26
const filename = frame . filePath ;
27
27
if ( filename ) {
28
- const ext = otherExts . find ( ( ext ) => filename . includes ( ext ) ) ;
28
+ const ext = otherExts . find ( ( ext ) => filename . includes ( ext . id ) ) ;
29
29
if ( ext ) {
30
- return ext ;
30
+ return ext . id ;
31
31
}
32
32
}
33
33
}
34
34
35
- // development mode
36
- const otherExtPaths = extensions . map ( ( ext ) => ext . extensionPath ) ;
37
- const candidates = frames . filter ( ( frame ) => otherExtPaths . includes ( frame . filePath ) ) ;
35
+ // `ms-python.vscode-python-envs` extension in Development mode
36
+ const candidates = frames . filter ( ( frame ) => otherExts . some ( ( s ) => frame . filePath . includes ( s . extensionPath ) ) ) ;
38
37
const envsExtPath = getExtension ( ENVS_EXTENSION_ID ) ?. extensionPath ;
39
38
if ( ! envsExtPath ) {
40
39
throw new Error ( 'Something went wrong with feature registration' ) ;
41
40
}
42
41
43
- if (
44
- candidates . length === 0 &&
45
- frames . filter ( ( frame ) => ! ! frame . filePath ) . every ( ( frame ) => frame . filePath . startsWith ( envsExtPath ) )
46
- ) {
42
+ if ( candidates . length === 0 && frames . every ( ( frame ) => frame . filePath . startsWith ( envsExtPath ) ) ) {
47
43
return PYTHON_EXTENSION_ID ;
48
44
}
49
45
50
- // get package json for the environment in candidate
51
- const candidateExt = extensions . find ( ( ext ) => ext . extensionPath === candidates [ 0 ] . filePath ) ;
46
+ // 3rd party extension in Development mode
47
+ const candidateExt = otherExts . find ( ( ext ) => candidates [ 0 ] . filePath . includes ( ext . extensionPath ) ) ;
52
48
if ( candidateExt ) {
53
49
return candidateExt . id ;
54
50
}
55
51
56
- throw new Error ( 'Unable to determine calling extension' ) ;
52
+ throw new Error ( 'Unable to determine calling extension id, registration failed ' ) ;
57
53
}
0 commit comments