From d2084031ba05c826fc6ea5ae281df3fb89ea1abe Mon Sep 17 00:00:00 2001 From: Brian Ignacio Date: Tue, 7 Jan 2025 19:06:21 +0800 Subject: [PATCH] update env var collection resolve undefined folder --- src/cdtDebugAdapter/debugConfProvider.ts | 9 +++++++++ src/utils.ts | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/cdtDebugAdapter/debugConfProvider.ts b/src/cdtDebugAdapter/debugConfProvider.ts index e1d6bdf25..40e15df6c 100644 --- a/src/cdtDebugAdapter/debugConfProvider.ts +++ b/src/cdtDebugAdapter/debugConfProvider.ts @@ -21,6 +21,7 @@ import { DebugConfiguration, DebugConfigurationProvider, WorkspaceFolder, + window } from "vscode"; import { readParameter } from "../idfConfiguration"; import { getIdfTargetFromSdkconfig, getProjectName } from "../workspaceConfig"; @@ -40,6 +41,14 @@ export class CDTDebugConfigurationProvider token?: CancellationToken ): Promise { try { + if (!folder) { + folder = await window.showWorkspaceFolderPick({ + placeHolder: "Pick a workspace folder to start a debug session.", + }); + if (!folder) { + throw new Error("No folder was selected to start debug session"); + } + } if (!config.program) { const buildDirPath = readParameter("idf.buildPath", folder) as string; const projectName = await getProjectName(buildDirPath); diff --git a/src/utils.ts b/src/utils.ts index 9e1d9d962..f2ccb14e1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1208,6 +1208,15 @@ export async function appendIdfAndToolsToPath(curWorkspace: vscode.Uri) { pathNameInEnv ] = `${IDF_ADD_PATHS_EXTRAS}${path.delimiter}${modifiedEnv[pathNameInEnv]}`; + extensionContext.environmentVariableCollection.replace( + pathNameInEnv, + modifiedEnv[pathNameInEnv], + { + applyAtShellIntegration: true, + applyAtProcessCreation: true, + } + ); + let idfTarget = await getIdfTargetFromSdkconfig(curWorkspace); if (idfTarget) { modifiedEnv.IDF_TARGET = idfTarget || process.env.IDF_TARGET;