Skip to content

Commit 205ea5f

Browse files
authored
Merge pull request microsoft#189302 from microsoft/ulugbekna/coherent-lemur
command "restart running task" now doesn't show quick pick if there's only one active task
2 parents 2bf4626 + 7cd1e2e commit 205ea5f

File tree

1 file changed

+31
-35
lines changed

1 file changed

+31
-35
lines changed

src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,48 +3114,44 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
31143114
}
31153115
}
31163116

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,
31203140
nls.localize('TaskService.taskToRestart', 'Select the task to restart'),
31213141
{
31223142
label: nls.localize('TaskService.noTaskToRestart', 'No task to restart'),
31233143
task: null
31243144
},
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);
31503150
}
31513151
} 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+
}
31593155
}
31603156
}
31613157

0 commit comments

Comments
 (0)