Skip to content

Commit 45e56c3

Browse files
flying-sheepCopilot
andcommitted
fix: try extensionId first
Co-authored-by: Copilot <copilot@github.com>
1 parent 1db132b commit 45e56c3

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

src/common/utils/frameUtils.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,28 @@ function getFrameData(): FrameData[] {
2222
}
2323

2424
function getPathFromFrame(frame: FrameData): string {
25-
if (frame.filePath && frame.filePath.startsWith('file://')) {
25+
if (frame.filePath?.startsWith('file://')) {
2626
return Uri.parse(frame.filePath).fsPath;
2727
}
2828
return frame.filePath;
2929
}
3030

31-
export function getCallingExtension(extensionIdHint?: string): string {
31+
export function getCallingExtension(extensionId?: string): string {
3232
const pythonExts = [ENVS_EXTENSION_ID, PYTHON_EXTENSION_ID];
3333
const extensions = allExtensions();
34+
35+
// Use the provided extensionId when available.
36+
// Only accept if it matches an actually loaded extension so we can always return something.
37+
if (extensionId) {
38+
const hintExt = extensions.find((ext) => ext.id === extensionId);
39+
if (hintExt) {
40+
traceVerbose(`Using provided extensionId: ${extensionId}`);
41+
return extensionId;
42+
}
43+
traceWarn(`Provided extensionId '${extensionId}' not found in loaded extensions, ignoring`);
44+
}
45+
46+
// Search the stack as a fallback when no extensionId is provided
3447
const otherExts = extensions.filter((ext) => !pythonExts.includes(ext.id));
3548
const frames = getFrameData();
3649

@@ -94,19 +107,6 @@ export function getCallingExtension(extensionIdHint?: string): string {
94107
}
95108
}
96109

97-
// Use the provided extensionId hint as a fallback (e.g., during F5 debugging where
98-
// stack-based detection fails because the file path doesn't contain the extension ID).
99-
// Only accept the hint if it matches an actually loaded extension for safety.
100-
if (extensionIdHint) {
101-
const hintExt = extensions.find((ext) => ext.id === extensionIdHint);
102-
if (hintExt) {
103-
traceVerbose(`Using provided extensionId hint: ${extensionIdHint}`);
104-
extensionIdCache.set(cacheKey, extensionIdHint);
105-
return extensionIdHint;
106-
}
107-
traceWarn(`Provided extensionId hint '${extensionIdHint}' not found in loaded extensions, ignoring`);
108-
}
109-
110110
// Fallback - we're likely being called from Python extension or built-in managers
111111
traceWarn(
112112
`Could not determine calling extension from stack frames. ` +

0 commit comments

Comments
 (0)