@@ -69,6 +69,7 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
6969 private _interactiveMode = false ;
7070 private _interactiveSecretPromise : Promise < void > | null = null ;
7171 private _interactorSecretResolver ?: ( ) => void ;
72+ private _donePromise : Promise < void > | null = null ;
7273 private _generatorState : State ;
7374 private _solutionState : State ;
7475 private _judgeState : State ;
@@ -281,17 +282,43 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
281282 }
282283
283284 async run ( ) : Promise < void > {
285+ const donePromise = this . _donePromise ;
286+ if ( donePromise ) {
287+ await donePromise ;
288+ return ;
289+ }
290+
284291 if ( ! this . _currentFile ) {
285292 return ;
286293 }
287294
295+ this . _donePromise = new Promise < void > ( ( resolve ) => {
296+ void ( async ( ) => {
297+ await this . _doRun ( ) ;
298+ resolve ( ) ;
299+ } ) ( ) ;
300+ } ) ;
301+ await this . _donePromise ;
302+ this . _donePromise = null ;
303+ }
304+
305+ stop ( ) {
306+ if ( this . _running ) {
307+ this . _stopFlag = true ;
308+ for ( const state of this . _state ) {
309+ state . process . stop ( ) ;
310+ }
311+ }
312+ }
313+
314+ private async _doRun ( ) {
288315 const config = vscode . workspace . getConfiguration ( "fastolympiccoding" ) ;
289316 const delayBetweenTestcases = config . get < number > ( "delayBetweenTestcases" ) ! ;
290317 const testcaseTimeLimit = config . get < number > ( "stressTestcaseTimeLimit" ) ! ;
291318 const testcaseMemoryLimit = config . get < number > ( "stressTestcaseMemoryLimit" ) ! ;
292319 const timeLimit = config . get < number > ( "stressTimeLimit" ) ! ;
293320
294- const solutionSettings = getFileRunSettings ( this . _currentFile ) ;
321+ const solutionSettings = getFileRunSettings ( this . _currentFile ! ) ;
295322 if ( ! solutionSettings ) {
296323 return ;
297324 }
@@ -351,7 +378,7 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
351378 }
352379 } ;
353380 addCompilePromise ( this . _generatorState , solutionSettings . generatorFile ! ) ;
354- addCompilePromise ( this . _solutionState , this . _currentFile ) ;
381+ addCompilePromise ( this . _solutionState , this . _currentFile ! ) ;
355382 if ( this . _interactiveMode ) {
356383 addCompilePromise ( this . _judgeState , solutionSettings . interactorFile ! ) ;
357384 } else {
@@ -543,15 +570,6 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
543570 this . _saveState ( ) ;
544571 }
545572
546- stop ( ) {
547- if ( this . _running ) {
548- this . _stopFlag = true ;
549- for ( const state of this . _state ) {
550- state . process . stop ( ) ;
551- }
552- }
553- }
554-
555573 private _view ( { id, stdio } : v . InferOutput < typeof ViewMessageSchema > ) {
556574 const state = this . _findState ( id ) ;
557575 if ( ! state ) {
0 commit comments