Skip to content

Commit

Permalink
debug: register providers only if the debugger extension is installed
Browse files Browse the repository at this point in the history
Providing debug configurations if the debugger extension is not
installed has 2 problems:
  * The debug configuration is listed in a menu item named "undefined"
  * The launch configuration will not work because the debugger does not
    exists
  • Loading branch information
ylatuya authored and tristan957 committed Aug 16, 2024
1 parent bdae9c8 commit 5720bde
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,19 @@ export async function activate(ctx: vscode.ExtensionContext) {
explorer = new MesonProjectExplorer(ctx, sourceDir, buildDir);

let providers = [];
if (os.platform() === "win32") {
providers.push(new MesonDebugConfigurationProvider(DebuggerType.cppvsdbg, buildDir));
} else {
providers.push(new MesonDebugConfigurationProvider(DebuggerType.cppdbg, buildDir));
// Install lldb provider if CodeLLDB extension is installed
if (vscode.extensions.getExtension("vadimcn.vscode-lldb")) {
providers.push(new MesonDebugConfigurationProvider(DebuggerType.lldb, buildDir));
}

// Install cppdbg or cppvsdbg provider if C/C++ extension is installed
if (vscode.extensions.getExtension("ms-vscode.cpptools")) {
if (os.platform() === "win32") {
providers.push(new MesonDebugConfigurationProvider(DebuggerType.cppvsdbg, buildDir));
} else {
providers.push(new MesonDebugConfigurationProvider(DebuggerType.cppdbg, buildDir));
}
}
providers.push(new MesonDebugConfigurationProvider(DebuggerType.lldb, buildDir));
providers.forEach((p) => {
ctx.subscriptions.push(
vscode.debug.registerDebugConfigurationProvider(
Expand Down

0 comments on commit 5720bde

Please sign in to comment.