parent
8335fcc3fc
commit
c91facce0a
|
@ -797,6 +797,13 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
|
|||
return tasks;
|
||||
}
|
||||
|
||||
public removeRecentlyUsedTask(taskRecentlyUsedKey: string) {
|
||||
if (this.getRecentlyUsedTasks().has(taskRecentlyUsedKey)) {
|
||||
this.getRecentlyUsedTasks().delete(taskRecentlyUsedKey);
|
||||
this.saveRecentlyUsedTasks();
|
||||
}
|
||||
}
|
||||
|
||||
private setTaskLRUCacheLimit() {
|
||||
const quickOpenHistoryLimit = this.configurationService.getValue<number>(QUICKOPEN_HISTORY_LIMIT_CONFIG);
|
||||
if (this._recentlyUsedTasks) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import { Task, ContributedTask, CustomTask, ConfiguringTask, TaskSorter, KeyedTa
|
|||
import { IWorkspace, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import * as Types from 'vs/base/common/types';
|
||||
import { ITaskService, WorkspaceFolderTaskResult } from 'vs/workbench/contrib/tasks/common/taskService';
|
||||
import { IQuickPickItem, QuickPickInput, IQuickPick } from 'vs/base/parts/quickinput/common/quickInput';
|
||||
import { IQuickPickItem, QuickPickInput, IQuickPick, IQuickInputButton } from 'vs/base/parts/quickinput/common/quickInput';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
|
@ -63,16 +63,17 @@ export class TaskQuickPick extends Disposable {
|
|||
return '';
|
||||
}
|
||||
|
||||
private createTaskEntry(task: Task | ConfiguringTask): TaskTwoLevelQuickPickEntry {
|
||||
private createTaskEntry(task: Task | ConfiguringTask, extraButtons: IQuickInputButton[] = []): TaskTwoLevelQuickPickEntry {
|
||||
const entry: TaskTwoLevelQuickPickEntry = { label: this.guessTaskLabel(task), description: this.taskService.getTaskDescription(task), task, detail: this.showDetail() ? task.configurationProperties.detail : undefined };
|
||||
entry.buttons = [{ iconClass: 'codicon-gear', tooltip: nls.localize('configureTask', "Configure Task") }];
|
||||
entry.buttons = [{ iconClass: 'codicon-gear', tooltip: nls.localize('configureTask', "Configure Task") }, ...extraButtons];
|
||||
return entry;
|
||||
}
|
||||
|
||||
private createEntriesForGroup(entries: QuickPickInput<TaskTwoLevelQuickPickEntry>[], tasks: (Task | ConfiguringTask)[], groupLabel: string) {
|
||||
private createEntriesForGroup(entries: QuickPickInput<TaskTwoLevelQuickPickEntry>[], tasks: (Task | ConfiguringTask)[],
|
||||
groupLabel: string, extraButtons: IQuickInputButton[] = []) {
|
||||
entries.push({ type: 'separator', label: groupLabel });
|
||||
tasks.forEach(task => {
|
||||
entries.push(this.createTaskEntry(task));
|
||||
entries.push(this.createTaskEntry(task, extraButtons));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -143,7 +144,11 @@ export class TaskQuickPick extends Disposable {
|
|||
let dedupedConfiguredTasks: (Task | ConfiguringTask)[] = dedupeAndPrune.configuredTasks;
|
||||
recentTasks = dedupeAndPrune.recentTasks;
|
||||
if (recentTasks.length > 0) {
|
||||
this.createEntriesForGroup(this.topLevelEntries, recentTasks, nls.localize('recentlyUsed', 'recently used'));
|
||||
const removeRecentButton: IQuickInputButton = {
|
||||
iconClass: 'codicon-close',
|
||||
tooltip: nls.localize('removeRecent', 'Remove Recently Used Task')
|
||||
};
|
||||
this.createEntriesForGroup(this.topLevelEntries, recentTasks, nls.localize('recentlyUsed', 'recently used'), [removeRecentButton]);
|
||||
}
|
||||
if (configuredTasks.length > 0) {
|
||||
if (dedupedConfiguredTasks.length > 0) {
|
||||
|
@ -171,6 +176,18 @@ export class TaskQuickPick extends Disposable {
|
|||
|
||||
picker.onDidTriggerItemButton(async (context) => {
|
||||
let task = context.item.task;
|
||||
if (task && !Types.isString(task) && context.button.iconClass === 'codicon-close') {
|
||||
const key = task.getRecentlyUsedKey();
|
||||
if (key) {
|
||||
this.taskService.removeRecentlyUsedTask(key);
|
||||
const indexToRemove = picker.items.indexOf(context.item);
|
||||
if (indexToRemove >= 0) {
|
||||
picker.items = [...picker.items.slice(0, indexToRemove), ...picker.items.slice(indexToRemove + 1)];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.quickInputService.cancel();
|
||||
if (ContributedTask.is(task)) {
|
||||
this.taskService.customize(task, undefined, true);
|
||||
|
|
|
@ -77,6 +77,7 @@ export interface ITaskService {
|
|||
taskTypes(): string[];
|
||||
getWorkspaceTasks(runSource?: TaskRunSource): Promise<Map<string, WorkspaceFolderTaskResult>>;
|
||||
readRecentTasks(): Promise<(Task | ConfiguringTask)[]>;
|
||||
removeRecentlyUsedTask(taskRecentlyUsedKey: string): void;
|
||||
/**
|
||||
* @param alias The task's name, label or defined identifier.
|
||||
*/
|
||||
|
|
|
@ -698,6 +698,7 @@ class SimpleTaskService implements ITaskService {
|
|||
tryResolveTask(configuringTask: ConfiguringTask): Promise<CustomTask | ContributedTask | InMemoryTask | undefined> { throw new Error('Method not implemented.'); }
|
||||
getTasksForGroup(group: string): Promise<Task[]> { throw new Error('Method not implemented.'); }
|
||||
getRecentlyUsedTasks(): LinkedMap<string, string> { throw new Error('Method not implemented.'); }
|
||||
removeRecentlyUsedTask(taskRecentlyUsedKey: string): void { throw new Error('Method not implemented.'); }
|
||||
migrateRecentTasks(tasks: Task[]): Promise<void> { throw new Error('Method not implemented.'); }
|
||||
createSorter(): TaskSorter { throw new Error('Method not implemented.'); }
|
||||
getTaskDescription(task: CustomTask | ContributedTask | InMemoryTask | ConfiguringTask): string | undefined { throw new Error('Method not implemented.'); }
|
||||
|
|
Loading…
Reference in a new issue