Skip to content

Commit 8ddc721

Browse files
committed
Fix 3rd party id during development
1 parent 9e99780 commit 8ddc721

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/common/utils/frameUtils.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,35 @@ export function getCallingExtension(): string {
1919
const pythonExts = [ENVS_EXTENSION_ID, PYTHON_EXTENSION_ID];
2020

2121
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);
2424

2525
for (const frame of frames) {
2626
const filename = frame.filePath;
2727
if (filename) {
28-
const ext = otherExts.find((ext) => filename.includes(ext));
28+
const ext = otherExts.find((ext) => filename.includes(ext.id));
2929
if (ext) {
30-
return ext;
30+
return ext.id;
3131
}
3232
}
3333
}
3434

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)));
3837
const envsExtPath = getExtension(ENVS_EXTENSION_ID)?.extensionPath;
3938
if (!envsExtPath) {
4039
throw new Error('Something went wrong with feature registration');
4140
}
4241

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))) {
4743
return PYTHON_EXTENSION_ID;
4844
}
4945

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));
5248
if (candidateExt) {
5349
return candidateExt.id;
5450
}
5551

56-
throw new Error('Unable to determine calling extension');
52+
throw new Error('Unable to determine calling extension id, registration failed');
5753
}

0 commit comments

Comments
 (0)