From eb6f9c23e19eae9015bd859941c5e8cbf4622cba Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 30 Apr 2020 15:25:04 +0300 Subject: pass Cargo errors to the Debug output channel --- editors/code/package.json | 2 +- editors/code/src/cargo.ts | 17 ++++++++++++----- editors/code/src/commands/runnables.ts | 7 ++++++- 3 files changed, 19 insertions(+), 7 deletions(-) (limited to 'editors') diff --git a/editors/code/package.json b/editors/code/package.json index 4f2df89ef..70a5c6619 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -399,7 +399,7 @@ "default": "auto", "description": "Preffered debug engine.", "markdownEnumDescriptions": [ - "First try to use [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb), if it's not installed use [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).", + "First try to use [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb), if it's not installed try to use [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).", "Use [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)", "Use [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools)" ] diff --git a/editors/code/src/cargo.ts b/editors/code/src/cargo.ts index 5999187f4..857b84d59 100644 --- a/editors/code/src/cargo.ts +++ b/editors/code/src/cargo.ts @@ -1,5 +1,6 @@ import * as cp from 'child_process'; import * as readline from 'readline'; +import { OutputChannel } from 'vscode'; interface CompilationArtifact { fileName: string; @@ -10,10 +11,13 @@ interface CompilationArtifact { export class Cargo { rootFolder: string; - env?: { [key: string]: string }; + env?: Record; + output: OutputChannel; - public constructor(cargoTomlFolder: string) { + public constructor(cargoTomlFolder: string, output: OutputChannel, env: Record | undefined = undefined) { this.rootFolder = cargoTomlFolder; + this.output = output; + this.env = env; } public async artifactsFromArgs(cargoArgs: string[]): Promise { @@ -34,14 +38,17 @@ export class Cargo { }) } } + else if( message.reason == 'compiler-message') { + this.output.append(message.message.rendered); + } }, - _stderr => { - // TODO: to output + stderr => { + this.output.append(stderr); } ); } catch (err) { - // TODO: to output + this.output.show(true); throw new Error(`Cargo invocation has failed: ${err}`); } diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 9b0780650..e8035c7d2 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -78,10 +78,15 @@ function getLldbDebugConfig(config: ra.Runnable, sourceFileMap: Record): Promise { - let cargo = new Cargo(config.cwd || '.'); + debugOutput.clear(); + + let cargo = new Cargo(config.cwd || '.', debugOutput); let executable = await cargo.executableFromArgs(config.args, config.extraArgs); + // if we are here, there were no compilation errors. return { type: (os.platform() === "win32") ? "cppvsdbg" : 'cppdbg', request: "launch", -- cgit v1.2.3