@@ -3114,48 +3114,44 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
3114
3114
}
3115
3115
}
3116
3116
3117
- private _runRestartTaskCommand ( arg ?: any ) : void {
3118
- const runQuickPick = ( promise ?: Promise < Task [ ] > ) => {
3119
- this . _showQuickPick ( promise || this . getActiveTasks ( ) ,
3117
+ private async _runRestartTaskCommand ( arg ?: any ) : Promise < void > {
3118
+
3119
+ const activeTasks = await this . getActiveTasks ( ) ;
3120
+
3121
+ if ( activeTasks . length === 1 ) {
3122
+ this . _restart ( activeTasks [ 0 ] ) ;
3123
+ return ;
3124
+ }
3125
+
3126
+ if ( this . inTerminal ( ) ) {
3127
+ // try dispatching using task identifier
3128
+ const identifier = this . _getTaskIdentifier ( arg ) ;
3129
+ if ( identifier !== undefined ) {
3130
+ for ( const task of activeTasks ) {
3131
+ if ( task . matches ( identifier ) ) {
3132
+ this . _restart ( task ) ;
3133
+ return ;
3134
+ }
3135
+ }
3136
+ }
3137
+ // show quick pick with active tasks
3138
+ const entry = await this . _showQuickPick (
3139
+ activeTasks ,
3120
3140
nls . localize ( 'TaskService.taskToRestart' , 'Select the task to restart' ) ,
3121
3141
{
3122
3142
label : nls . localize ( 'TaskService.noTaskToRestart' , 'No task to restart' ) ,
3123
3143
task : null
3124
3144
} ,
3125
- false , true
3126
- ) . then ( entry => {
3127
- const task : Task | undefined | null = entry ? entry . task : undefined ;
3128
- if ( task === undefined || task === null ) {
3129
- return ;
3130
- }
3131
- this . _restart ( task ) ;
3132
- } ) ;
3133
- } ;
3134
- if ( this . inTerminal ( ) ) {
3135
- const identifier = this . _getTaskIdentifier ( arg ) ;
3136
- let promise : Promise < Task [ ] > ;
3137
- if ( identifier !== undefined ) {
3138
- promise = this . getActiveTasks ( ) ;
3139
- promise . then ( ( tasks ) => {
3140
- for ( const task of tasks ) {
3141
- if ( task . matches ( identifier ) ) {
3142
- this . _restart ( task ) ;
3143
- return ;
3144
- }
3145
- }
3146
- runQuickPick ( promise ) ;
3147
- } ) ;
3148
- } else {
3149
- runQuickPick ( ) ;
3145
+ false ,
3146
+ true
3147
+ ) ;
3148
+ if ( entry && entry . task ) {
3149
+ this . _restart ( entry . task ) ;
3150
3150
}
3151
3151
} else {
3152
- this . getActiveTasks ( ) . then ( ( activeTasks ) => {
3153
- if ( activeTasks . length === 0 ) {
3154
- return ;
3155
- }
3156
- const task = activeTasks [ 0 ] ;
3157
- this . _restart ( task ) ;
3158
- } ) ;
3152
+ if ( activeTasks . length > 0 ) {
3153
+ this . _restart ( activeTasks [ 0 ] ) ;
3154
+ }
3159
3155
}
3160
3156
}
3161
3157
0 commit comments