提交 a152a5c7 编写于 作者: A Alex Ross

Add task names to automatic task notification

Fixes #64427
上级 86571ec5
......@@ -30,11 +30,13 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
this.taskService.getWorkspaceTasks(TaskRunSource.FolderOpen).then(workspaceTaskResult => {
if (workspaceTaskResult) {
const tasks = new Array<Task | Promise<Task>>();
const taskNames = new Array<string>();
workspaceTaskResult.forEach(resultElement => {
if (resultElement.set) {
resultElement.set.tasks.forEach(task => {
if (task.runOptions.runOn === RunOnOptions.folderOpen) {
tasks.push(task);
taskNames.push(task._label);
}
});
}
......@@ -44,6 +46,11 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
tasks.push(new Promise<Task>(resolve => {
this.taskService.getTask(resultElement.workspaceFolder, configedTask.value._id, true).then(task => resolve(task));
}));
if (configedTask.value._label) {
taskNames.push(configedTask.value._label);
} else {
taskNames.push(configedTask.value.configures.task);
}
}
});
}
......@@ -52,7 +59,7 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
if (tasks.length > 0) {
// We have automatic tasks, prompt to run it if we don't already have permission.
if (isAllowed === undefined) {
this.showPrompt().then(postPromptAllowed => {
this.showPrompt(taskNames).then(postPromptAllowed => {
if (postPromptAllowed) {
this.runTasks(tasks);
}
......@@ -80,9 +87,15 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
});
}
private showPrompt(): Promise<boolean> {
private showPrompt(taskNames: Array<string>): Promise<boolean> {
// We will only show the prompt if their are automatic tasks, so taskNames is at least of length 1.
let taskNamesPrint: string = '(' + taskNames[0];
for (let i = 1; i < taskNames.length; i++) {
taskNamesPrint += ', ' + taskNames[i];
}
taskNamesPrint += ')';
return new Promise<boolean>(resolve => {
this.notificationService.prompt(Severity.Info, nls.localize('tasks.run.allowAutomatic', "This folder has tasks defined in \'tasks.json\' that run automatically when you open this folder. Do you allow automatic tasks to run when you open this folder?"),
this.notificationService.prompt(Severity.Info, nls.localize('tasks.run.allowAutomatic', "This folder has tasks {0} defined in \'tasks.json\' that run automatically when you open this folder. Do you allow automatic tasks to run when you open this folder?", taskNamesPrint),
[{
label: nls.localize('allow', "Allow"),
run: () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册