aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r--editors/code/src/commands/runnables.ts33
1 files changed, 25 insertions, 8 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts
index 26db18156..befb8b366 100644
--- a/editors/code/src/commands/runnables.ts
+++ b/editors/code/src/commands/runnables.ts
@@ -63,7 +63,7 @@ export function runSingle(ctx: Ctx): Cmd {
63 }; 63 };
64} 64}
65 65
66function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration { 66function getLldbDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): vscode.DebugConfiguration {
67 return { 67 return {
68 type: "lldb", 68 type: "lldb",
69 request: "launch", 69 request: "launch",
@@ -72,11 +72,12 @@ function getLldbDebugConfig(config: ra.Runnable) : vscode.DebugConfiguration {
72 args: config.args, 72 args: config.args,
73 }, 73 },
74 args: config.extraArgs, 74 args: config.extraArgs,
75 cwd: config.cwd 75 cwd: config.cwd,
76 sourceMap: sourceFileMap
76 }; 77 };
77} 78}
78 79
79async function getCppvsDebugConfig(config: ra.Runnable) : Promise<vscode.DebugConfiguration> { 80async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): Promise<vscode.DebugConfiguration> {
80 let cargo = new Cargo(config.cwd || '.'); 81 let cargo = new Cargo(config.cwd || '.');
81 let executable = await cargo.executableFromArgs(config.args, config.extraArgs); 82 let executable = await cargo.executableFromArgs(config.args, config.extraArgs);
82 83
@@ -87,6 +88,7 @@ async function getCppvsDebugConfig(config: ra.Runnable) : Promise<vscode.DebugCo
87 program: executable, 88 program: executable,
88 args: config.extraArgs, 89 args: config.extraArgs,
89 cwd: config.cwd, 90 cwd: config.cwd,
91 sourceFileMap: sourceFileMap,
90 }; 92 };
91} 93}
92 94
@@ -95,15 +97,30 @@ export function debugSingle(ctx: Ctx): Cmd {
95 const editor = ctx.activeRustEditor; 97 const editor = ctx.activeRustEditor;
96 if (!editor) return; 98 if (!editor) return;
97 99
98 const mscpp = vscode.extensions.getExtension("ms-vscode.cpptools"); 100 const lldbId = "vadimcn.vscode-lldb";
99 const lldb = vscode.extensions.getExtension("vadimcn.vscode-lldb"); 101 const cpptoolsId = "ms-vscode.cpptools";
102
103 let debugEngineId = ctx.config.debug.engine;
104 let debugEngine = null;
105 if (!debugEngineId) {
106 debugEngine = vscode.extensions.getExtension(lldbId);
107 if (!debugEngine) {
108 debugEngine = vscode.extensions.getExtension(cpptoolsId);
109 }
110 }
111 else {
112 debugEngine = vscode.extensions.getExtension(debugEngineId);
113 }
100 114
101 if (!(lldb || mscpp)) { 115 if (!debugEngine) {
102 vscode.window.showErrorMessage("Install `vadimcn.vscode-lldb` or `ms-vscode.cpptools` extension for debugging"); 116 vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=${lldbId})`
117 + ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=${cpptoolsId}) extension for debugging.`);
103 return; 118 return;
104 } 119 }
105 120
106 const debugConfig = lldb ? getLldbDebugConfig(config) : await getCppvsDebugConfig(config); 121 const debugConfig = lldbId == debugEngine.id
122 ? getLldbDebugConfig(config, ctx.config.debug.sourceFileMap)
123 : await getCppvsDebugConfig(config, ctx.config.debug.sourceFileMap);
107 124
108 return vscode.debug.startDebugging(undefined, debugConfig); 125 return vscode.debug.startDebugging(undefined, debugConfig);
109 }; 126 };