Skip to content

Commit 1269431

Browse files
committed
Fix debugger restart button not working
The restart button has never worked. This makes it work, but now we have a pause button enabled that doesn't do anything.
1 parent 21e7498 commit 1269431

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
77
### Added
88
- New "interactiveTerminal" debugger option to run remote programs in
99
interactive terminal instead of output pane
10+
### Fixed
11+
- Fix debugger restart button not working
1012
### Changed
1113
- SSH shell no longer requires native executable on Windows
1214

src/debugServer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class Ev3devBrowserDebugSession extends DebugSession {
2424

2525
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
2626
this.sendEvent(new Event('ev3devBrowser.debugger.launch', args));
27-
// We don't send a response so that the pause button does not become enabled.
27+
this.sendResponse(response);
2828
}
2929

3030
protected customRequest(command: string, response: DebugProtocol.Response, args: any): void {
@@ -38,7 +38,7 @@ export class Ev3devBrowserDebugSession extends DebugSession {
3838

3939
protected disconnectRequest(response: DebugProtocol.DisconnectResponse,
4040
args: DebugProtocol.DisconnectArguments): void {
41-
this.sendEvent(new Event('ev3devBrowser.debugger.stop'));
41+
this.sendEvent(new Event('ev3devBrowser.debugger.stop', args));
4242
this.sendResponse(response);
4343
}
4444
}

src/extension.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ async function pickDevice(): Promise<void> {
111111

112112
const activeDebugSessions = new Set<string>();
113113
let debugTerminal: vscode.Terminal;
114+
let debugRestarting: boolean;
114115

115116
async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Promise<void> {
116117
let device: Device | undefined;
@@ -177,7 +178,11 @@ async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Pr
177178
},
178179
});
179180
ch.on('close', () => {
180-
event.session.customRequest('ev3devBrowser.debugger.terminate');
181+
if (debugRestarting) {
182+
activeDebugSessions.add(event.session.id);
183+
} else {
184+
event.session.customRequest('ev3devBrowser.debugger.terminate');
185+
}
181186
ch.destroy();
182187
});
183188
ch.on('exit', (code, signal, coreDump, desc) => {
@@ -206,20 +211,29 @@ async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Pr
206211
output.appendLine(`Starting: ${command}`);
207212
const channel = await device.exec(command);
208213
channel.on('close', () => {
209-
event.session.customRequest('ev3devBrowser.debugger.terminate');
214+
if (debugRestarting) {
215+
activeDebugSessions.add(event.session.id);
216+
output.clear();
217+
output.appendLine(`Restarting: ${command}`);
218+
output.appendLine('----------');
219+
} else {
220+
event.session.customRequest('ev3devBrowser.debugger.terminate');
221+
}
210222
});
211223
channel.on('exit', (code, signal, coreDump, desc) => {
212-
output.appendLine('----------');
213-
if (code === 0) {
214-
output.appendLine('Completed successfully.');
215-
}
216-
else if (code) {
217-
output.appendLine(`Exited with error code ${code}.`);
218-
}
219-
else {
220-
output.appendLine(`Exited with signal ${signal}.`);
224+
if (!debugRestarting) {
225+
output.appendLine('----------');
226+
if (code === 0) {
227+
output.appendLine('Completed successfully.');
228+
}
229+
else if (code) {
230+
output.appendLine(`Exited with error code ${code}.`);
231+
}
232+
else {
233+
output.appendLine(`Exited with signal ${signal}.`);
234+
}
235+
activeDebugSessions.delete(event.session.id);
221236
}
222-
activeDebugSessions.delete(event.session.id);
223237
});
224238
channel.on('data', (chunk: string | Buffer) => {
225239
output.append(chunk.toString());
@@ -237,6 +251,7 @@ async function handleCustomDebugEvent(event: vscode.DebugSessionCustomEvent): Pr
237251
}
238252
break;
239253
case 'ev3devBrowser.debugger.stop':
254+
debugRestarting = event.body.restart;
240255
device = ev3devBrowserProvider.getDeviceSync();
241256
if (activeDebugSessions.has(event.session.id) && device && device.isConnected) {
242257
device.exec('conrun-kill --signal=SIGKILL');

0 commit comments

Comments
 (0)