Skip to content

Commit a152a5c

Browse files
committed
Add task names to automatic task notification
Fixes microsoft#64427
1 parent 86571ec commit a152a5c

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/vs/workbench/parts/tasks/electron-browser/runAutomaticTasks.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
3030
this.taskService.getWorkspaceTasks(TaskRunSource.FolderOpen).then(workspaceTaskResult => {
3131
if (workspaceTaskResult) {
3232
const tasks = new Array<Task | Promise<Task>>();
33+
const taskNames = new Array<string>();
3334
workspaceTaskResult.forEach(resultElement => {
3435
if (resultElement.set) {
3536
resultElement.set.tasks.forEach(task => {
3637
if (task.runOptions.runOn === RunOnOptions.folderOpen) {
3738
tasks.push(task);
39+
taskNames.push(task._label);
3840
}
3941
});
4042
}
@@ -44,6 +46,11 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
4446
tasks.push(new Promise<Task>(resolve => {
4547
this.taskService.getTask(resultElement.workspaceFolder, configedTask.value._id, true).then(task => resolve(task));
4648
}));
49+
if (configedTask.value._label) {
50+
taskNames.push(configedTask.value._label);
51+
} else {
52+
taskNames.push(configedTask.value.configures.task);
53+
}
4754
}
4855
});
4956
}
@@ -52,7 +59,7 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
5259
if (tasks.length > 0) {
5360
// We have automatic tasks, prompt to run it if we don't already have permission.
5461
if (isAllowed === undefined) {
55-
this.showPrompt().then(postPromptAllowed => {
62+
this.showPrompt(taskNames).then(postPromptAllowed => {
5663
if (postPromptAllowed) {
5764
this.runTasks(tasks);
5865
}
@@ -80,9 +87,15 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
8087
});
8188
}
8289

83-
private showPrompt(): Promise<boolean> {
90+
private showPrompt(taskNames: Array<string>): Promise<boolean> {
91+
// We will only show the prompt if their are automatic tasks, so taskNames is at least of length 1.
92+
let taskNamesPrint: string = '(' + taskNames[0];
93+
for (let i = 1; i < taskNames.length; i++) {
94+
taskNamesPrint += ', ' + taskNames[i];
95+
}
96+
taskNamesPrint += ')';
8497
return new Promise<boolean>(resolve => {
85-
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?"),
98+
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),
8699
[{
87100
label: nls.localize('allow', "Allow"),
88101
run: () => {

0 commit comments

Comments
 (0)