Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Start without debugging should fallback to debug mode when program is…
Browse files Browse the repository at this point in the history
… not a file Fixes #1084
  • Loading branch information
ramya-rao-a committed Jul 17, 2017
1 parent c8841f6 commit 4caeaec
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class Delve {
onstdout: (str: string) => void;
onstderr: (str: string) => void;
onclose: (code: number) => void;
noDebug: boolean;

constructor(remotePath: string, port: number, host: string, program: string, launchArgs: LaunchRequestArguments) {
this.program = program;
Expand Down Expand Up @@ -216,30 +217,32 @@ class Delve {
}

let env = Object.assign({}, process.env, fileEnv, launchArgs.env);
if (!!launchArgs.noDebug && mode === 'debug' && !isProgramDirectory) {
this.debugProcess = spawn(getGoRuntimePath(), ['run', program], { env });
this.debugProcess.stderr.on('data', chunk => {
let str = chunk.toString();
if (this.onstderr) { this.onstderr(str); }
});
this.debugProcess.stdout.on('data', chunk => {
let str = chunk.toString();
if (this.onstdout) { this.onstdout(str); }
});
this.debugProcess.on('close', (code) => {
logError('Process exiting with code: ' + code);
if (this.onclose) { this.onclose(code); }
});
this.debugProcess.on('error', function (err) {
reject(err);
});
resolve();
return;
if (!!launchArgs.noDebug) {
if (mode === 'debug' && !isProgramDirectory) {
this.noDebug = true;
this.debugProcess = spawn(getGoRuntimePath(), ['run', program], { env });
this.debugProcess.stderr.on('data', chunk => {
let str = chunk.toString();
if (this.onstderr) { this.onstderr(str); }
});
this.debugProcess.stdout.on('data', chunk => {
let str = chunk.toString();
if (this.onstdout) { this.onstdout(str); }
});
this.debugProcess.on('close', (code) => {
logError('Process exiting with code: ' + code);
if (this.onclose) { this.onclose(code); }
});
this.debugProcess.on('error', function (err) {
reject(err);
});
resolve();
return;
}
}

this.noDebug = false;
let serverRunning = false;


if (mode === 'remote') {
this.debugProcess = null;
serverRunning = true; // assume server is running when in remote mode
Expand Down Expand Up @@ -444,7 +447,7 @@ class GoDebugSession extends DebugSession {
};

this.delve.connection.then(() => {
if (!args.noDebug) {
if (!this.delve.noDebug) {
this.sendEvent(new InitializedEvent());
verbose('InitializeEvent');
}
Expand Down

0 comments on commit 4caeaec

Please sign in to comment.