diff options
author | Megan Rogge <merogge@microsoft.com> | 2022-07-06 18:54:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-06 18:54:37 +0300 |
commit | 0df86c37b602d08bab3e8def45dd445d36f55fc2 (patch) | |
tree | 7813dd22449dd6e1bcf7c0ae99e6cc4170521a6c /src/vs/workbench | |
parent | f9f353c90becae9610fc28f5b47078ce859eaa00 (diff) |
add `hide` property to configure which tasks appear in the `Tasks: run task` quickpick (#154166)
Diffstat (limited to 'src/vs/workbench')
8 files changed, 64 insertions, 20 deletions
diff --git a/src/vs/workbench/api/browser/mainThreadTask.ts b/src/vs/workbench/api/browser/mainThreadTask.ts index 69e679cc5b4..d6193015b85 100644 --- a/src/vs/workbench/api/browser/mainThreadTask.ts +++ b/src/vs/workbench/api/browser/mainThreadTask.ts @@ -342,7 +342,7 @@ namespace TaskDTO { return result; } - export function to(task: ITaskDTO | undefined, workspace: IWorkspaceContextService, executeOnly: boolean, icon?: { id?: string; color?: string }): ContributedTask | undefined { + export function to(task: ITaskDTO | undefined, workspace: IWorkspaceContextService, executeOnly: boolean, icon?: { id?: string; color?: string }, hide?: boolean): ContributedTask | undefined { if (!task || (typeof task.name !== 'string')) { return undefined; } @@ -383,7 +383,8 @@ namespace TaskDTO { isBackground: !!task.isBackground, problemMatchers: task.problemMatchers.slice(), detail: task.detail, - icon + icon, + hide } ); return result; @@ -492,7 +493,7 @@ export class MainThreadTask implements MainThreadTaskShape { dto.name = ((dto.name === undefined) ? '' : dto.name); // Using an empty name causes the name to default to the one given by the provider. return Promise.resolve(this._proxy.$resolveTask(handle, dto)).then(resolvedTask => { if (resolvedTask) { - return TaskDTO.to(resolvedTask, this._workspaceContextServer, true, task.configurationProperties.icon); + return TaskDTO.to(resolvedTask, this._workspaceContextServer, true, task.configurationProperties.icon, task.configurationProperties.hide); } return undefined; diff --git a/src/vs/workbench/api/common/shared/tasks.ts b/src/vs/workbench/api/common/shared/tasks.ts index f7f206f0649..6f0445ab393 100644 --- a/src/vs/workbench/api/common/shared/tasks.ts +++ b/src/vs/workbench/api/common/shared/tasks.ts @@ -78,6 +78,7 @@ export interface ITaskSourceDTO { scope?: number | UriComponents; color?: string; icon?: string; + hide?: boolean; } export interface ITaskHandleDTO { diff --git a/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts b/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts index 9ef8982eebe..da7e0dccf58 100644 --- a/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts +++ b/src/vs/workbench/contrib/tasks/browser/abstractTaskService.ts @@ -1588,7 +1588,7 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer { identifier: id, dependsOn: extensionTasks.map((extensionTask) => { return { uri: extensionTask.getWorkspaceFolder()!.uri, task: extensionTask._id }; }), - name: id, + name: id } ); return { task, resolver }; diff --git a/src/vs/workbench/contrib/tasks/browser/taskQuickPick.ts b/src/vs/workbench/contrib/tasks/browser/taskQuickPick.ts index 77dc6f60769..a2cc123e381 100644 --- a/src/vs/workbench/contrib/tasks/browser/taskQuickPick.ts +++ b/src/vs/workbench/contrib/tasks/browser/taskQuickPick.ts @@ -24,7 +24,6 @@ import { TaskQuickPickEntryType } from 'vs/workbench/contrib/tasks/browser/abstr export const QUICKOPEN_DETAIL_CONFIG = 'task.quickOpen.detail'; export const QUICKOPEN_SKIP_CONFIG = 'task.quickOpen.skip'; - export function isWorkspaceFolder(folder: IWorkspace | IWorkspaceFolder): folder is IWorkspaceFolder { return 'uri' in folder; } @@ -108,7 +107,9 @@ export class TaskQuickPick extends Disposable { groupLabel: string, extraButtons: IQuickInputButton[] = []) { entries.push({ type: 'separator', label: groupLabel }); tasks.forEach(task => { - entries.push(this._createTaskEntry(task, extraButtons)); + if (!task.configurationProperties.hide) { + entries.push(this._createTaskEntry(task, extraButtons)); + } }); } @@ -304,7 +305,7 @@ export class TaskQuickPick extends Disposable { private async _doPickerSecondLevel(picker: IQuickPick<ITaskTwoLevelQuickPickEntry>, type: string) { picker.busy = true; if (type === SHOW_ALL) { - const items = (await this._taskService.tasks()).sort((a, b) => this._sorter.compare(a, b)).map(task => this._createTaskEntry(task)); + const items = (await this._taskService.tasks()).filter(t => !t.configurationProperties.hide).sort((a, b) => this._sorter.compare(a, b)).map(task => this._createTaskEntry(task)); items.push(...TaskQuickPick.allSettingEntries(this._configurationService)); picker.items = items; } else { @@ -353,9 +354,13 @@ export class TaskQuickPick extends Disposable { private async _getEntriesForProvider(type: string): Promise<QuickPickInput<ITaskTwoLevelQuickPickEntry>[]> { const tasks = (await this._taskService.tasks({ type })).sort((a, b) => this._sorter.compare(a, b)); - let taskQuickPickEntries: QuickPickInput<ITaskTwoLevelQuickPickEntry>[]; + let taskQuickPickEntries: QuickPickInput<ITaskTwoLevelQuickPickEntry>[] = []; if (tasks.length > 0) { - taskQuickPickEntries = tasks.map(task => this._createTaskEntry(task)); + for (const task of tasks) { + if (!task.configurationProperties.hide) { + taskQuickPickEntries.push(this._createTaskEntry(task)); + } + } taskQuickPickEntries.push({ type: 'separator' }, { diff --git a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts index d1dd693f370..0beaded25b4 100644 --- a/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts +++ b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts @@ -516,12 +516,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem { for (const dependency of task.configurationProperties.dependsOn) { const dependencyTask = await resolver.resolve(dependency.uri, dependency.task!); if (dependencyTask) { - if (dependencyTask.configurationProperties.icon) { - dependencyTask.configurationProperties.icon.id ||= task.configurationProperties.icon?.id; - dependencyTask.configurationProperties.icon.color ||= task.configurationProperties.icon?.color; - } else { - dependencyTask.configurationProperties.icon = task.configurationProperties.icon; - } + this._adoptConfigurationForDependencyTask(dependencyTask, task); const key = dependencyTask.getMapKey(); let promise = this._activeTasks[key] ? this._getDependencyPromise(this._activeTasks[key]) : undefined; if (!promise) { @@ -590,6 +585,21 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem { }); } + private _adoptConfigurationForDependencyTask(dependencyTask: Task, task: Task): void { + if (dependencyTask.configurationProperties.icon) { + dependencyTask.configurationProperties.icon.id ||= task.configurationProperties.icon?.id; + dependencyTask.configurationProperties.icon.color ||= task.configurationProperties.icon?.color; + } else { + dependencyTask.configurationProperties.icon = task.configurationProperties.icon; + } + + if (dependencyTask.configurationProperties.hide) { + dependencyTask.configurationProperties.hide ||= task.configurationProperties.hide; + } else { + dependencyTask.configurationProperties.hide = task.configurationProperties.hide; + } + } + private async _getDependencyPromise(task: IActiveTerminalData): Promise<ITaskSummary> { if (!task.task.configurationProperties.isBackground) { return task.promise; diff --git a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts index 077bd89a60e..fa67f8ecf65 100644 --- a/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts +++ b/src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts @@ -45,6 +45,13 @@ const shellCommand: IJSONSchema = { deprecationMessage: nls.localize('JsonSchema.tasks.isShellCommand.deprecated', 'The property isShellCommand is deprecated. Use the type property of the task and the shell property in the options instead. See also the 1.14 release notes.') }; + +const hide: IJSONSchema = { + type: 'boolean', + description: nls.localize('JsonSchema.hide', 'Hide this task from the run task quick pick'), + default: true +}; + const taskIdentifier: IJSONSchema = { type: 'object', additionalProperties: true, @@ -407,6 +414,7 @@ const taskConfiguration: IJSONSchema = { }, presentation: Objects.deepClone(presentation), icon: Objects.deepClone(icon), + hide: Objects.deepClone(hide), options: options, problemMatcher: { $ref: '#/definitions/problemMatcherType', @@ -479,6 +487,7 @@ taskDescriptionProperties.command = Objects.deepClone(command); taskDescriptionProperties.args = Objects.deepClone(args); taskDescriptionProperties.isShellCommand = Objects.deepClone(shellCommand); taskDescriptionProperties.dependsOn = dependsOn; +taskDescriptionProperties.hide = Objects.deepClone(hide); taskDescriptionProperties.dependsOrder = dependsOrder; taskDescriptionProperties.identifier = Objects.deepClone(identifier); taskDescriptionProperties.type = Objects.deepClone(taskType); diff --git a/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts b/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts index c5d4058bcb0..0bb00f57620 100644 --- a/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts +++ b/src/vs/workbench/contrib/tasks/common/taskConfiguration.ts @@ -362,6 +362,11 @@ export interface IConfigurationProperties { * The icon's color in the terminal tabs list */ color?: string; + + /** + * Do not show this task in the run task quickpick + */ + hide?: boolean; } export interface ICustomTask extends ICommandProperties, IConfigurationProperties { @@ -1322,7 +1327,8 @@ namespace ConfigurationProperties { { property: 'presentation', type: CommandConfiguration.PresentationOptions }, { property: 'problemMatchers' }, { property: 'options' }, - { property: 'icon' } + { property: 'icon' }, + { property: 'hide' } ]; export function from(this: void, external: IConfigurationProperties & { [key: string]: any }, context: IParseContext, @@ -1350,7 +1356,7 @@ namespace ConfigurationProperties { result.identifier = external.identifier; } result.icon = external.icon; - + result.hide = external.hide; if (external.isBackground !== undefined) { result.isBackground = !!external.isBackground; } @@ -1483,7 +1489,7 @@ namespace ConfiguringTask { type, taskIdentifier, RunOptions.fromConfiguration(external.runOptions), - {} + { hide: external.hide } ); const configuration = ConfigurationProperties.from(external, context, true, source, typeDeclaration.properties); result.addTaskLoadMessages(configuration.errors); @@ -1635,7 +1641,8 @@ namespace CustomTask { { name: configuredProps.configurationProperties.name || contributedTask.configurationProperties.name, identifier: configuredProps.configurationProperties.identifier || contributedTask.configurationProperties.identifier, - icon: configuredProps.configurationProperties.icon + icon: configuredProps.configurationProperties.icon, + hide: configuredProps.configurationProperties.hide }, ); @@ -2119,7 +2126,7 @@ class ConfigurationParser { identifier: name, group: Tasks.TaskGroup.Build, isBackground: isBackground, - problemMatchers: matchers, + problemMatchers: matchers } ); const taskGroupKind = GroupKind.from(fileConfig.group); diff --git a/src/vs/workbench/contrib/tasks/common/tasks.ts b/src/vs/workbench/contrib/tasks/common/tasks.ts index 1b52c33d02a..f4956cc9aef 100644 --- a/src/vs/workbench/contrib/tasks/common/tasks.ts +++ b/src/vs/workbench/contrib/tasks/common/tasks.ts @@ -549,6 +549,11 @@ export interface IConfigurationProperties { * The icon for this task in the terminal tabs list */ icon?: { id?: string; color?: string }; + + /** + * Do not show this task in the run task quickpick + */ + hide?: boolean; } export enum RunOnOptions { @@ -914,6 +919,11 @@ export class ContributedTask extends CommonTask { */ icon: { id?: string; color?: string } | undefined; + /** + * Don't show the task in the run task quickpick + */ + hide?: boolean; + public constructor(id: string, source: IExtensionTaskSource, label: string, type: string | undefined, defines: KeyedTaskIdentifier, command: ICommandConfiguration, hasDefinedMatchers: boolean, runOptions: IRunOptions, configurationProperties: IConfigurationProperties) { @@ -922,6 +932,7 @@ export class ContributedTask extends CommonTask { this.hasDefinedMatchers = hasDefinedMatchers; this.command = command; this.icon = configurationProperties.icon; + this.hide = configurationProperties.hide; } public override clone(): ContributedTask { |