Skip to content

Commit

Permalink
Fixes #29623: Restart task is not triggered from command and top leve…
Browse files Browse the repository at this point in the history
…l menu
  • Loading branch information
dbaeumer committed Jun 27, 2017
1 parent 75082c7 commit fe276c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 149 deletions.
58 changes: 0 additions & 58 deletions src/vs/workbench/parts/tasks/browser/restartQuickOpen.ts

This file was deleted.

58 changes: 0 additions & 58 deletions src/vs/workbench/parts/tasks/browser/terminateQuickOpen.ts

This file was deleted.

54 changes: 21 additions & 33 deletions src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import 'vs/css!./media/task.contribution';
import 'vs/workbench/parts/tasks/browser/taskQuickOpen';
import 'vs/workbench/parts/tasks/browser/terminateQuickOpen';
import 'vs/workbench/parts/tasks/browser/restartQuickOpen';
import 'vs/workbench/parts/tasks/browser/buildQuickOpen';
import 'vs/workbench/parts/tasks/browser/testQuickOpen';

Expand Down Expand Up @@ -59,7 +57,7 @@ import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } fro
import { IStatusbarItem, IStatusbarRegistry, Extensions as StatusbarExtensions, StatusbarItemDescriptor, StatusbarAlignment } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';

import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { IQuickOpenService, IPickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import Constants from 'vs/workbench/parts/markers/common/constants';
import { IPartService } from 'vs/workbench/services/part/common/partService';
Expand Down Expand Up @@ -1549,13 +1547,14 @@ class TaskService extends EventEmitter implements ITaskService {
if (this.inTerminal()) {
this.getActiveTasks().then((activeTasks) => {
if (activeTasks.length === 0) {
this.messageService.show(Severity.Info, nls.localize('TaskService.noTaskRunning', 'No task running.'));
return;
}
if (activeTasks.length === 1) {
this.terminate(activeTasks[0]);
} else {
this.quickOpenService.show('terminate task ');
}
this.showQuickPick(activeTasks, nls.localize('TaskService.tastToTerminate', 'Select task to terminate')).then(task => {
if (task) {
this.terminate(task);
}
});
});
} else {
this.isActive().then((active) => {
Expand All @@ -1577,20 +1576,29 @@ class TaskService extends EventEmitter implements ITaskService {
}
}

private showQuickPick(tasks: Task[], placeHolder: string): TPromise<Task> {
interface TaskQickPickEntry extends IPickOpenEntry {
task: Task;
}
let entries: TaskQickPickEntry[] = tasks.map<TaskQickPickEntry>(task => { return { label: task._label, task }; });
return this.quickOpenService.pick(entries, { placeHolder }).then(entry => entry ? entry.task : undefined);
}

private runRestartTaskCommand(accessor: ServicesAccessor, arg: any): void {
if (!this.canRunCommand()) {
return;
}
if (this.inTerminal()) {
this.getActiveTasks().then((activeTasks) => {
if (activeTasks.length === 0) {
this.messageService.show(Severity.Info, nls.localize('TaskService.noTaskToRestart', 'No task to restart.'));
return;
}
if (activeTasks.length === 1) {
this.restart(activeTasks[0]);
} else {
this.quickOpenService.show('restart task ');
}
this.showQuickPick(activeTasks, nls.localize('TaskService.tastToRestart', 'Select the task to restart')).then(task => {
if (task) {
this.restart(task);
}
});
});
} else {
this.getActiveTasks().then((activeTasks) => {
Expand Down Expand Up @@ -1634,26 +1642,6 @@ quickOpenRegistry.registerQuickOpenHandler(
)
);

quickOpenRegistry.registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
'vs/workbench/parts/tasks/browser/terminateQuickOpen',
'QuickOpenHandler',
'terminate task ',
tasksPickerContextKey,
nls.localize('quickOpen.terminateTask', "Terminate Task")
)
);

quickOpenRegistry.registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
'vs/workbench/parts/tasks/browser/restartQuickOpen',
'QuickOpenHandler',
'restart task ',
tasksPickerContextKey,
nls.localize('quickOpen.restartTask', "Restart Task")
)
);

quickOpenRegistry.registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
'vs/workbench/parts/tasks/browser/buildQuickOpen',
Expand Down

0 comments on commit fe276c9

Please sign in to comment.