Commit 15ef6257 authored by abbycin's avatar abbycin

fix restart and stop issue

parent 32f0f937
{
"name": "topjs-debugger",
"displayName": "TopJS Debugger",
"version": "0.0.2",
"version": "0.0.3",
"publisher": "AbbyCin",
"description": "TopJS debugger extension for VS Code.",
"author": {
......
......@@ -43,6 +43,20 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession {
this.setDebuggerColumnsStartAt1(false);
this._cachedBreakpoints = {};
this._restart = false;
// overwrite event in base class
// when close stop button
this.on('close', () => {
this.terminateSession('exit');
super.shutdown();
});
this.on('error', (error) => {
this.terminateSession('exit');
super.shutdown();
});
// runtime instance for interacting with debugger backend
this._runtime = new topjsRuntime.topjsRuntime();
......@@ -150,7 +164,7 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession {
spawn.execSync(`${TASK_KILL} /F /T /PID ${processId}`);
}
catch (err) {
this.err(err);
//this.err(err.message);
}
}
else {
......@@ -168,7 +182,10 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession {
let argv = [`--remote-debugging-port=${args.port}`, args.program];
this._backend = spawn.spawn(args.runtimeExecutable, argv);
this._backend.on('exit', () => {
if(!this._restart) {
this._restart = false;
this.sendEvent(new vscode_debugadapter.TerminatedEvent());
}
if(this.isExtensionHost()) {
this.terminateSession(msg);
}
......@@ -178,7 +195,10 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession {
if(!this.isExtensionHost()) {
this.terminateSession(msg);
}
if(!this._restart) {
this._restart = false;
this.sendEvent(new vscode_debugadapter.TerminatedEvent());
}
process.exit(0);
});
this._backend.stdout.on('data', (data) => {
......@@ -190,7 +210,10 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession {
this._backend.on('error', (err) => {
this.err(err.message());
this.err('main process exit...');
if(!this._restart) {
this._restart = false;
this.sendEvent(new vscode_debugadapter.TerminatedEvent());
}
process.exit(1);
});
this.log([args.runtimeExecutable, `--remote-debugging-port=${args.port}`, Path.basename(args.program)].join(' '));
......@@ -362,6 +385,7 @@ class TopJSDebugSession extends vscode_debugadapter.LoggingDebugSession {
}
restartRequest(response, args) {
this._restart = true;
this._runtime.quit();
this.terminateSession('restart');
this.spawnBackend(this._args);
......
......@@ -277,9 +277,9 @@ class topjsRuntime extends events.EventEmitter {
quit() {
try {
this.client.disconnect();
this.client.destroy('close');
} catch(e) {
//this._logger.log(`disconnect: ${e}`);
}
this._started = false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment