@@ -152,6 +152,7 @@ export class TerminalTaskSystem implements ITaskSystem {
152152 } ;
153153
154154 private activeTasks : IStringDictionary < ActiveTerminalData > ;
155+ private busyTasks : IStringDictionary < Task > ;
155156 private terminals : IStringDictionary < TerminalData > ;
156157 private idleTaskTerminals : LinkedMap < string , string > ;
157158 private sameTaskTerminals : IStringDictionary < string > ;
@@ -180,6 +181,7 @@ export class TerminalTaskSystem implements ITaskSystem {
180181 ) {
181182
182183 this . activeTasks = Object . create ( null ) ;
184+ this . busyTasks = Object . create ( null ) ;
183185 this . terminals = Object . create ( null ) ;
184186 this . idleTaskTerminals = new LinkedMap < string , string > ( ) ;
185187 this . sameTaskTerminals = Object . create ( null ) ;
@@ -280,6 +282,10 @@ export class TerminalTaskSystem implements ITaskSystem {
280282 return Object . keys ( this . activeTasks ) . map ( key => this . activeTasks [ key ] . task ) ;
281283 }
282284
285+ public getBusyTasks ( ) : Task [ ] {
286+ return Object . keys ( this . busyTasks ) . map ( key => this . busyTasks [ key ] ) ;
287+ }
288+
283289 public customExecutionComplete ( task : Task , result : number ) : Promise < void > {
284290 let activeTerminal = this . activeTasks [ task . getMapKey ( ) ] ;
285291 if ( ! activeTerminal ) {
@@ -533,12 +539,17 @@ export class TerminalTaskSystem implements ITaskSystem {
533539 }
534540 const toDispose = new DisposableStore ( ) ;
535541 let eventCounter : number = 0 ;
542+ const mapKey = task . getMapKey ( ) ;
536543 toDispose . add ( watchingProblemMatcher . onDidStateChange ( ( event ) => {
537544 if ( event . kind === ProblemCollectorEventKind . BackgroundProcessingBegins ) {
538545 eventCounter ++ ;
546+ this . busyTasks [ mapKey ] = task ;
539547 this . _onDidStateChange . fire ( TaskEvent . create ( TaskEventKind . Active , task ) ) ;
540548 } else if ( event . kind === ProblemCollectorEventKind . BackgroundProcessingEnds ) {
541549 eventCounter -- ;
550+ if ( this . busyTasks [ mapKey ] ) {
551+ delete this . busyTasks [ mapKey ] ;
552+ }
542553 this . _onDidStateChange . fire ( TaskEvent . create ( TaskEventKind . Inactive , task ) ) ;
543554 if ( eventCounter === 0 ) {
544555 if ( ( watchingProblemMatcher . numberOfMatches > 0 ) && watchingProblemMatcher . maxMarkerSeverity &&
@@ -597,6 +608,9 @@ export class TerminalTaskSystem implements ITaskSystem {
597608 onData . dispose ( ) ;
598609 onExit . dispose ( ) ;
599610 let key = task . getMapKey ( ) ;
611+ if ( this . busyTasks [ mapKey ] ) {
612+ delete this . busyTasks [ mapKey ] ;
613+ }
600614 delete this . activeTasks [ key ] ;
601615 this . _onDidStateChange . fire ( TaskEvent . create ( TaskEventKind . Changed ) ) ;
602616 if ( exitCode !== undefined ) {
@@ -656,6 +670,8 @@ export class TerminalTaskSystem implements ITaskSystem {
656670 // The process never got ready. Need to think how to handle this.
657671 } ) ;
658672 this . _onDidStateChange . fire ( TaskEvent . create ( TaskEventKind . Start , task , terminal . id ) ) ;
673+ const mapKey = task . getMapKey ( ) ;
674+ this . busyTasks [ mapKey ] = task ;
659675 this . _onDidStateChange . fire ( TaskEvent . create ( TaskEventKind . Active , task ) ) ;
660676 let problemMatchers = this . resolveMatchers ( resolver , task . configurationProperties . problemMatchers ) ;
661677 let startStopProblemMatcher = new StartStopProblemCollector ( problemMatchers , this . markerService , this . modelService , ProblemHandlingStrategy . Clean , this . fileService ) ;
@@ -709,6 +725,9 @@ export class TerminalTaskSystem implements ITaskSystem {
709725 }
710726
711727 this . _onDidStateChange . fire ( TaskEvent . create ( TaskEventKind . ProcessEnded , task , exitCode ) ) ;
728+ if ( this . busyTasks [ mapKey ] ) {
729+ delete this . busyTasks [ mapKey ] ;
730+ }
712731 this . _onDidStateChange . fire ( TaskEvent . create ( TaskEventKind . Inactive , task ) ) ;
713732 this . _onDidStateChange . fire ( TaskEvent . create ( TaskEventKind . End , task ) ) ;
714733 resolve ( { exitCode } ) ;
@@ -1028,7 +1047,11 @@ export class TerminalTaskSystem implements ITaskSystem {
10281047 // This can happen if the terminal wasn't shutdown with an "immediate" flag and is expected.
10291048 // For correct terminal re-use, the task needs to be deleted immediately.
10301049 // Note that this shouldn't be a problem anymore since user initiated terminal kills are now immediate.
1031- delete this . activeTasks [ task . getMapKey ( ) ] ;
1050+ const mapKey = task . getMapKey ( ) ;
1051+ delete this . activeTasks [ mapKey ] ;
1052+ if ( this . busyTasks [ mapKey ] ) {
1053+ delete this . busyTasks [ mapKey ] ;
1054+ }
10321055 }
10331056 } ) ;
10341057 this . terminals [ terminalKey ] = { terminal : result , lastTask : taskKey , group } ;
0 commit comments