Skip to content

Commit

Permalink
Temporarily fix #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackwaly committed Jun 24, 2016
1 parent 9fbf207 commit 5879fa3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/debug/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"stopOnEntry": false,
"args": [ "--server=4711" ],
"sourceMaps": true,
"env": {
"DEBUG_VSCODE_OCAML": "development"
},
"outDir": "${workspaceRoot}/../../out/src/debug"
}
]
Expand Down
13 changes: 8 additions & 5 deletions src/debug/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,22 @@ class OCamlDebugSession extends DebugSession {
readUntilPrompt(callback?) {
return new Promise((resolve) => {
let buffer = '';
let onData = (chunk) => {
buffer += chunk.toString('utf-8').replace(/\r\n/g, '\n');
if (callback) callback(buffer);
let timer;
let onTimeout = () => {
if (buffer.slice(-6) === '(ocd) ') {
let output = buffer.slice(0, -6);
output = output.replace(/\n$/, '');
log(`ocd: ${JSON.stringify(output)}`);
resolve(output);
this._debuggerProc.stdout.removeListener('data', onData);
return;
}
};
let onData = (chunk) => {
buffer += chunk.toString('utf-8').replace(/\r\n/g, '\n');
if (callback) callback(buffer);
clearTimeout(timer);
setTimeout(onTimeout, 64);
};
this._debuggerProc.stdout.on('data', onData);
});
}
Expand Down Expand Up @@ -163,7 +167,6 @@ class OCamlDebugSession extends DebugSession {
ocdArgs.push(path.normalize(args.program));

this._launchArgs = args;
console.log(ocdArgs);
this._debuggerProc = child_process.spawn('ocamldebug', ocdArgs);
this._breakpoints = new Map();

Expand Down

0 comments on commit 5879fa3

Please sign in to comment.