diff --git a/Extension/CHANGELOG.md b/Extension/CHANGELOG.md index 46f04925cf..c973f6f639 100644 --- a/Extension/CHANGELOG.md +++ b/Extension/CHANGELOG.md @@ -19,6 +19,7 @@ ### Bug Fixes * Fix code folding causing `} else if` lines to be hidden. [#5521](https://github.com/microsoft/vscode-cpptools/issues/5521) +* Fix empty `launch.json` being created when debug configuration selection is canceled. [#7517](https://github.com/microsoft/vscode-cpptools/issues/7517) * Fix Find All References on a global variable giving incorrect references to local variables. [#7702](https://github.com/microsoft/vscode-cpptools/issues/7702) * Fix `vcFormat` not working near the end of the file with UTF-8 characters > 1 byte. [#7704](https://github.com/microsoft/vscode-cpptools/issues/7704) * Fix configuration squiggle on a recursively resolved `forcedInclude`. [PR #7722](https://github.com/microsoft/vscode-cpptools/pull/7722) diff --git a/Extension/src/Debugger/configurationProvider.ts b/Extension/src/Debugger/configurationProvider.ts index 90b70ff6df..6126c92830 100644 --- a/Extension/src/Debugger/configurationProvider.ts +++ b/Extension/src/Debugger/configurationProvider.ts @@ -71,7 +71,7 @@ export class QuickPickConfigurationProvider implements vscode.DebugConfiguration const selection: MenuItem | undefined = await vscode.window.showQuickPick(items, {placeHolder: localize("select.configuration", "Select a configuration")}); if (!selection) { - return []; // User canceled it. + throw Error(localize("debug.configuration.selection.canceled", "Debug configuration selection canceled")); // User canceled it. } if (selection.label.startsWith("cl.exe")) { if (!process.env.DevEnvDir) { @@ -161,11 +161,11 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { return false; } if (defaultConfig.name.startsWith("(Windows) ")) { - if (command.includes("cl.exe")) { + if (command.startsWith("cl.exe")) { return true; } } else { - if (!command.includes("cl.exe")) { + if (!command.startsWith("cl.exe")) { return true; } } @@ -203,9 +203,16 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { let debuggerName: string; if (compilerName.startsWith("clang")) { newConfig.MIMode = "lldb"; - const suffixIndex: number = compilerName.indexOf("-"); - const suffix: string = suffixIndex === -1 ? "" : compilerName.substr(suffixIndex); - debuggerName = "lldb-mi" + suffix; + debuggerName = "lldb-mi"; + // Search for clang-8, clang-10, etc. + if ((compilerName !== "clang-cl.exe") && (compilerName !== "clang-cpp.exe")) { + const suffixIndex: number = compilerName.indexOf("-"); + if (suffixIndex !== -1) { + const suffix: string = compilerName.substr(suffixIndex); + debuggerName += suffix; + } + } + newConfig.type = "cppdbg"; } else if (compilerName === "cl.exe") { newConfig.miDebuggerPath = undefined; newConfig.type = "cppvsdbg"; @@ -213,11 +220,9 @@ class CppConfigurationProvider implements vscode.DebugConfigurationProvider { } else { debuggerName = "gdb"; } - if (isWindows) { - debuggerName += ".exe"; + debuggerName = debuggerName.endsWith(".exe") ? debuggerName : (debuggerName + ".exe"); } - const compilerDirname: string = path.dirname(compilerPath); const debuggerPath: string = path.join(compilerDirname, debuggerName); if (isWindows) {