@@ -111,6 +111,7 @@ async function pickDevice(): Promise<void> {
111111
112112const activeDebugSessions = new Set < string > ( ) ;
113113let debugTerminal : vscode . Terminal ;
114+ let debugRestarting : boolean ;
114115
115116async 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