Skip to content

Commit 34a9a5e

Browse files
committed
Add setting to disable fast tasks picker
Fixes microsoft#95358
1 parent 711dac0 commit 34a9a5e

2 files changed

Lines changed: 74 additions & 19 deletions

File tree

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

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import { isWorkspaceFolder, TaskQuickPickEntry, QUICKOPEN_DETAIL_CONFIG, TaskQui
8484

8585
const QUICKOPEN_HISTORY_LIMIT_CONFIG = 'task.quickOpen.history';
8686
const PROBLEM_MATCHER_NEVER_CONFIG = 'task.problemMatchers.neverPrompt';
87+
const USE_SLOW_PICKER = 'task.quickOpen.showAll';
8788

8889
export namespace ConfigureTaskAction {
8990
export const ID = 'workbench.action.tasks.configureTaskRunner';
@@ -2255,7 +2256,6 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
22552256
const picker: IQuickPick<TaskQuickPickEntry> = this.quickInputService.createQuickPick();
22562257
picker.placeholder = placeHolder;
22572258
picker.matchOnDescription = true;
2258-
picker.ignoreFocusOut = true;
22592259

22602260
picker.onDidTriggerItemButton(context => {
22612261
let task = context.item.task;
@@ -2367,26 +2367,76 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
23672367
}
23682368
}
23692369

2370-
private doRunTaskCommand(tasks?: Task[]): void {
2371-
this.showIgnoredFoldersMessage().then(() => {
2372-
this.showTwoLevelQuickPick(
2373-
nls.localize('TaskService.pickRunTask', 'Select the task to run'),
2374-
{
2375-
label: nls.localize('TaskService.noEntryToRun', 'No configured tasks. Configure Tasks...'),
2376-
task: null
2377-
}).
2378-
then((task) => {
2379-
if (task === undefined) {
2380-
return;
2381-
}
2382-
if (task === null) {
2383-
this.runConfigureTasks();
2384-
} else {
2385-
this.run(task, { attachProblemMatcher: true }, TaskRunSource.User).then(undefined, reason => {
2386-
// eat the error, it has already been surfaced to the user and we don't care about it here
2387-
});
2370+
private tasksAndGroupedTasks(filter?: TaskFilter): { tasks: Promise<Task[]>, grouped: Promise<TaskMap> } {
2371+
if (!this.versionAndEngineCompatible(filter)) {
2372+
return { tasks: Promise.resolve<Task[]>([]), grouped: Promise.resolve(new TaskMap()) };
2373+
}
2374+
const grouped = this.getGroupedTasks(filter ? filter.type : undefined);
2375+
const tasks = grouped.then((map) => {
2376+
if (!filter || !filter.type) {
2377+
return map.all();
2378+
}
2379+
let result: Task[] = [];
2380+
map.forEach((tasks) => {
2381+
for (let task of tasks) {
2382+
if (ContributedTask.is(task) && task.defines.type === filter.type) {
2383+
result.push(task);
2384+
} else if (CustomTask.is(task)) {
2385+
if (task.type === filter.type) {
2386+
result.push(task);
2387+
} else {
2388+
let customizes = task.customizes();
2389+
if (customizes && customizes.type === filter.type) {
2390+
result.push(task);
2391+
}
2392+
}
23882393
}
2394+
}
2395+
});
2396+
return result;
2397+
});
2398+
return { tasks, grouped };
2399+
}
2400+
2401+
private doRunTaskCommand(tasks?: Task[]): void {
2402+
const pickThen = (task: Task | undefined | null) => {
2403+
if (task === undefined) {
2404+
return;
2405+
}
2406+
if (task === null) {
2407+
this.runConfigureTasks();
2408+
} else {
2409+
this.run(task, { attachProblemMatcher: true }, TaskRunSource.User).then(undefined, reason => {
2410+
// eat the error, it has already been surfaced to the user and we don't care about it here
23892411
});
2412+
}
2413+
};
2414+
2415+
const placeholder = nls.localize('TaskService.pickRunTask', 'Select the task to run');
2416+
2417+
this.showIgnoredFoldersMessage().then(() => {
2418+
if (this.configurationService.getValue(USE_SLOW_PICKER)) {
2419+
let taskResult: { tasks: Promise<Task[]>, grouped: Promise<TaskMap> } | undefined = undefined;
2420+
if (!tasks) {
2421+
taskResult = this.tasksAndGroupedTasks();
2422+
}
2423+
this.showQuickPick(tasks ? tasks : taskResult!.tasks, placeholder,
2424+
{
2425+
label: nls.localize('TaskService.noEntryToRunSlow', 'No task to run found. Configure Tasks...'),
2426+
task: null
2427+
},
2428+
true).
2429+
then((entry) => {
2430+
return pickThen(entry ? entry.task : undefined);
2431+
});
2432+
} else {
2433+
this.showTwoLevelQuickPick(placeholder,
2434+
{
2435+
label: nls.localize('TaskService.noEntryToRun', 'No configured tasks. Configure Tasks...'),
2436+
task: null
2437+
}).
2438+
then(pickThen);
2439+
}
23902440
});
23912441
}
23922442

src/vs/workbench/contrib/tasks/browser/task.contribution.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ configurationRegistry.registerConfiguration({
377377
description: nls.localize('task.quickOpen.skip', "Controls whether the task quick pick is skipped when there is only one task to pick from."),
378378
default: false
379379
},
380+
'task.quickOpen.showAll': {
381+
type: 'boolean',
382+
description: nls.localize('task.quickOpen.showAll', "Causes the Tasks: Run Task command to use the slower \"show all\" behavior instead of the faster two level picker where tasks are grouped by provider."),
383+
default: false
384+
},
380385
'task.saveBeforeRun': {
381386
markdownDescription: nls.localize(
382387
'task.saveBeforeRun',

0 commit comments

Comments
 (0)