Skip to content

Commit 16c2a3a

Browse files
authored
revert quickpick changes, get to work for build task, and address fee… (microsoft#152106)
1 parent d466785 commit 16c2a3a

File tree

7 files changed

+55
-119
lines changed

7 files changed

+55
-119
lines changed

src/vs/workbench/api/browser/mainThreadTask.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,6 @@ namespace TaskDTO {
318318
isBackground: task.configurationProperties.isBackground,
319319
problemMatchers: [],
320320
hasDefinedMatchers: ContributedTask.is(task) ? task.hasDefinedMatchers : false,
321-
icon: task.configurationProperties.icon,
322-
color: task.configurationProperties.color,
323321
runOptions: RunOptionsDTO.from(task.runOptions),
324322
};
325323
result.group = TaskGroupDTO.from(task.configurationProperties.group);
@@ -344,7 +342,7 @@ namespace TaskDTO {
344342
return result;
345343
}
346344

347-
export function to(task: ITaskDTO | undefined, workspace: IWorkspaceContextService, executeOnly: boolean): ContributedTask | undefined {
345+
export function to(task: ITaskDTO | undefined, workspace: IWorkspaceContextService, executeOnly: boolean, icon?: { id: string; color?: string }): ContributedTask | undefined {
348346
if (!task || (typeof task.name !== 'string')) {
349347
return undefined;
350348
}
@@ -385,8 +383,7 @@ namespace TaskDTO {
385383
isBackground: !!task.isBackground,
386384
problemMatchers: task.problemMatchers.slice(),
387385
detail: task.detail,
388-
color: task.color,
389-
icon: task.icon
386+
icon
390387
}
391388
);
392389
return result;
@@ -495,7 +492,7 @@ export class MainThreadTask implements MainThreadTaskShape {
495492
dto.name = ((dto.name === undefined) ? '' : dto.name); // Using an empty name causes the name to default to the one given by the provider.
496493
return Promise.resolve(this._proxy.$resolveTask(handle, dto)).then(resolvedTask => {
497494
if (resolvedTask) {
498-
return TaskDTO.to(resolvedTask, this._workspaceContextServer, true);
495+
return TaskDTO.to(resolvedTask, this._workspaceContextServer, true, task.configurationProperties.icon);
499496
}
500497

501498
return undefined;

src/vs/workbench/api/common/shared/tasks.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ export interface ITaskDTO {
103103
problemMatchers: string[];
104104
hasDefinedMatchers: boolean;
105105
runOptions?: IRunOptionsDTO;
106-
color?: string;
107-
icon?: string;
108106
}
109107

110108
export interface ITaskSetDTO {

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

Lines changed: 10 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ import { Task, ContributedTask, CustomTask, ConfiguringTask, TaskSorter, KeyedTa
99
import { IWorkspace, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
1010
import * as Types from 'vs/base/common/types';
1111
import { ITaskService, IWorkspaceFolderTaskResult } from 'vs/workbench/contrib/tasks/common/taskService';
12-
import { IQuickPickItem, QuickPickInput, IQuickPick, IQuickInputButton, IQuickPickSeparator } from 'vs/base/parts/quickinput/common/quickInput';
12+
import { IQuickPickItem, QuickPickInput, IQuickPick, IQuickInputButton } from 'vs/base/parts/quickinput/common/quickInput';
1313
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1414
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
15-
import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle';
15+
import { Disposable } from 'vs/base/common/lifecycle';
1616
import { Event } from 'vs/base/common/event';
1717
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
1818
import { Codicon } from 'vs/base/common/codicons';
1919
import { IThemeService, ThemeIcon } from 'vs/platform/theme/common/themeService';
2020
import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
2121
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
22-
import { getColorClass, getColorStyleElement, getStandardColors } from 'vs/workbench/contrib/terminal/browser/terminalIcon';
22+
import { getColorClass, getColorStyleElement } from 'vs/workbench/contrib/terminal/browser/terminalIcon';
2323
import { TaskQuickPickEntryType } from 'vs/workbench/contrib/tasks/browser/abstractTaskService';
2424

2525
export const QUICKOPEN_DETAIL_CONFIG = 'task.quickOpen.detail';
@@ -78,25 +78,25 @@ export class TaskQuickPick extends Disposable {
7878
}
7979

8080
public static getTaskLabelWithIcon(task: Task | ConfiguringTask): string {
81-
return task.configurationProperties.icon ? `$(${task.configurationProperties.icon}) ${task._label}` : task.configurationProperties.color ? `$(${Codicon.tools.id}) ${task._label}` : `${task._label}`;
81+
const icon = task.configurationProperties.icon;
82+
if (!icon) {
83+
return `${task._label}`;
84+
}
85+
return icon.id ? `$(${icon.id}) ${task._label}` : `$(${Codicon.tools.id}) ${task._label}`;
8286
}
8387

8488
public static applyColorStyles(task: Task | ConfiguringTask, entry: TaskQuickPickEntryType | ITaskTwoLevelQuickPickEntry, themeService: IThemeService): void {
85-
if (task.configurationProperties.color) {
89+
if (task.configurationProperties.icon?.color) {
8690
const colorTheme = themeService.getColorTheme();
8791
const styleElement = getColorStyleElement(colorTheme);
88-
entry.iconClasses = [getColorClass(task.configurationProperties.color)];
92+
entry.iconClasses = [getColorClass(task.configurationProperties.icon.color)];
8993
document.body.appendChild(styleElement);
9094
}
9195
}
9296

9397
private _createTaskEntry(task: Task | ConfiguringTask, extraButtons: IQuickInputButton[] = []): ITaskTwoLevelQuickPickEntry {
94-
const customizeIconButton = { iconClass: ThemeIcon.asClassName(Codicon.pencil), tooltip: nls.localize('setIconAndColor', "Choose color and icon") };
9598
const entry: ITaskTwoLevelQuickPickEntry = { label: this._guessTaskLabel(task), description: this._taskService.getTaskDescription(task), task, detail: this._showDetail() ? task.configurationProperties.detail : undefined };
9699
entry.buttons = [];
97-
if (CustomTask.is(task)) {
98-
entry.buttons.push(customizeIconButton);
99-
}
100100
entry.buttons.push({ iconClass: ThemeIcon.asClassName(configureTaskIcon), tooltip: nls.localize('configureTask', "Configure Task") });
101101
entry.buttons.push(...extraButtons);
102102
TaskQuickPick.applyColorStyles(task, entry, this._themeService);
@@ -234,9 +234,6 @@ export class TaskQuickPick extends Disposable {
234234
if (indexToRemove >= 0) {
235235
picker.items = [...picker.items.slice(0, indexToRemove), ...picker.items.slice(indexToRemove + 1)];
236236
}
237-
} else if (context.button.iconClass = ThemeIcon.asClassName(Codicon.pencil)) {
238-
await this._setColor(task);
239-
await this._setIcon(task);
240237
} else {
241238
this._quickInputService.cancel();
242239
if (ContributedTask.is(task)) {
@@ -291,72 +288,6 @@ export class TaskQuickPick extends Disposable {
291288
return;
292289
}
293290

294-
private async _setColor(task: Task | ConfiguringTask | null | string | undefined): Promise<void> {
295-
if (task === undefined || task === null || typeof task === 'string') {
296-
return;
297-
}
298-
const colorTheme = this._themeService.getColorTheme();
299-
const standardColors: string[] = getStandardColors(colorTheme);
300-
const styleElement = getColorStyleElement(colorTheme);
301-
const items: (IQuickPickItem | IQuickPickSeparator)[] = [];
302-
for (const colorKey of standardColors) {
303-
const colorClass = getColorClass(colorKey);
304-
items.push({
305-
label: `$(${Codicon.circleFilled.id}) ${colorKey.replace('terminal.ansi', '')}`, id: colorKey, description: colorKey, iconClasses: [colorClass]
306-
});
307-
}
308-
items.push({ type: 'separator' });
309-
const showAllColorsItem = { label: 'Reset to default' };
310-
items.push(showAllColorsItem);
311-
document.body.appendChild(styleElement);
312-
313-
const quickPick = this._quickInputService.createQuickPick();
314-
quickPick.items = items;
315-
quickPick.matchOnDescription = true;
316-
quickPick.show();
317-
const disposables: IDisposable[] = [];
318-
const result = await new Promise<IQuickPickItem | undefined>(r => {
319-
disposables.push(quickPick.onDidHide(() => r(undefined)));
320-
disposables.push(quickPick.onDidAccept(() => r(quickPick.selectedItems[0])));
321-
});
322-
dispose(disposables);
323-
324-
if (result && task && typeof task !== 'string') {
325-
task.configurationProperties.color = result.id;
326-
}
327-
document.body.removeChild(styleElement);
328-
quickPick.hide();
329-
}
330-
331-
private async _setIcon(task: Task | ConfiguringTask | null | string | undefined): Promise<void> {
332-
if (task === undefined || task === null || typeof task === 'string') {
333-
return;
334-
}
335-
type Item = IQuickPickItem & { icon: ThemeIcon };
336-
const items: Item[] = [];
337-
for (const icon of Codicon.getAll()) {
338-
items.push({ label: `$(${icon.id})`, description: `${icon.id}`, id: icon.id, icon, iconClasses: task.configurationProperties.color ? [getColorClass(task.configurationProperties.color)] : undefined });
339-
}
340-
341-
const quickPick = this._quickInputService.createQuickPick();
342-
quickPick.items = items;
343-
quickPick.matchOnDescription = true;
344-
quickPick.show();
345-
const disposables: IDisposable[] = [];
346-
const result = await new Promise<IQuickPickItem | undefined>(r => {
347-
disposables.push(quickPick.onDidHide(() => r(undefined)));
348-
disposables.push(quickPick.onDidAccept(() => r(quickPick.selectedItems[0])));
349-
});
350-
dispose(disposables);
351-
352-
if (result && task && typeof task !== 'string') {
353-
task.configurationProperties.icon = result.id;
354-
}
355-
if (CustomTask.is(task) && result) {
356-
await this._taskService.customize(task, { icon: result.id, color: task.configurationProperties.color }, false);
357-
}
358-
quickPick.hide();
359-
}
360291

361292

362293
private async _doPickerFirstLevel(picker: IQuickPick<ITaskTwoLevelQuickPickEntry>, taskQuickPickEntries: QuickPickInput<ITaskTwoLevelQuickPickEntry>[]): Promise<Task | ConfiguringTask | string | null | undefined> {

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
508508
for (const dependency of task.configurationProperties.dependsOn) {
509509
const dependencyTask = await resolver.resolve(dependency.uri, dependency.task!);
510510
if (dependencyTask) {
511+
dependencyTask.configurationProperties.icon = task.configurationProperties.icon;
511512
const key = dependencyTask.getMapKey();
512513
let promise = this._activeTasks[key] ? this._getDependencyPromise(this._activeTasks[key]) : undefined;
513514
if (!promise) {
@@ -1033,7 +1034,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
10331034
});
10341035
let icon: URI | ThemeIcon | { light: URI; dark: URI } | undefined;
10351036
if (task.configurationProperties.icon) {
1036-
icon = ThemeIcon.fromId(task.configurationProperties.icon);
1037+
icon = ThemeIcon.fromId(task.configurationProperties.icon.id);
10371038
} else {
10381039
const taskGroupKind = task.configurationProperties.group ? GroupKind.to(task.configurationProperties.group) : undefined;
10391040
const kindId = typeof taskGroupKind === 'string' ? taskGroupKind : taskGroupKind?.kind;
@@ -1046,7 +1047,7 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
10461047
args: defaultProfile.args,
10471048
env: { ...defaultProfile.env },
10481049
icon,
1049-
color: task.configurationProperties.color || defaultProfile.color,
1050+
color: task.configurationProperties.icon?.color || undefined,
10501051
waitOnExit
10511052
};
10521053
let shellSpecified: boolean = false;
@@ -1143,8 +1144,8 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
11431144
shellLaunchConfig = {
11441145
name: terminalName,
11451146
type,
1146-
icon: task.configurationProperties.icon ? ThemeIcon.fromId(task.configurationProperties.icon) : undefined,
1147-
color: task.configurationProperties.color,
1147+
icon: task.configurationProperties.icon?.id ? ThemeIcon.fromId(task.configurationProperties.icon.id) : undefined,
1148+
color: task.configurationProperties.icon?.color || undefined,
11481149
executable: executable,
11491150
args: args.map(a => Types.isString(a) ? a : a.value),
11501151
waitOnExit
@@ -1273,8 +1274,8 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
12731274
comment: ['The task command line or label']
12741275
}, 'Executing task: {0}', task._label), { excludeLeadingNewLine: true }) : undefined,
12751276
isFeatureTerminal: true,
1276-
icon: task.configurationProperties.icon ? ThemeIcon.fromId(task.configurationProperties.icon) : undefined,
1277-
color: task.configurationProperties.color
1277+
icon: task.configurationProperties.icon?.id ? ThemeIcon.fromId(task.configurationProperties.icon.id) : undefined,
1278+
color: task.configurationProperties.icon?.color || undefined,
12781279
};
12791280
} else {
12801281
const resolvedResult: { command: CommandString; args: CommandString[] } = await this._resolveCommandAndArgs(resolver, task.command);

src/vs/workbench/contrib/tasks/common/jsonSchema_v2.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ProblemMatcherRegistry } from 'vs/workbench/contrib/tasks/common/proble
1313
import { TaskDefinitionRegistry } from './taskDefinitionRegistry';
1414
import * as ConfigurationResolverUtils from 'vs/workbench/services/configurationResolver/common/configurationResolverUtils';
1515
import { inputsSchema } from 'vs/workbench/services/configurationResolver/common/configurationResolverSchema';
16+
import { Codicon } from 'vs/base/common/codicons';
1617

1718
function fixReferences(literal: any) {
1819
if (Array.isArray(literal)) {
@@ -94,14 +95,30 @@ const detail: IJSONSchema = {
9495
description: nls.localize('JsonSchema.tasks.detail', 'An optional description of a task that shows in the Run Task quick pick as a detail.')
9596
};
9697

97-
const color: IJSONSchema = {
98-
type: 'string',
99-
description: nls.localize('JsonSchema.tasks.color', 'An optional color for the task icon')
100-
};
101-
10298
const icon: IJSONSchema = {
103-
type: 'string',
104-
description: nls.localize('JsonSchema.tasks.icon', 'An optional icon for the task')
99+
type: 'object',
100+
properties: {
101+
id: {
102+
description: nls.localize('JsonSchema.tasks.icon.id', 'An optional icon for the task'),
103+
type: 'string',
104+
enum: Array.from(Codicon.getAll(), icon => icon.id),
105+
markdownEnumDescriptions: Array.from(Codicon.getAll(), icon => `$(${icon.id})`),
106+
},
107+
color: {
108+
description: nls.localize('JsonSchema.tasks.icon.color', 'An optional color to use for the task icon'),
109+
type: ['string', 'null'],
110+
enum: [
111+
'terminal.ansiBlack',
112+
'terminal.ansiRed',
113+
'terminal.ansiGreen',
114+
'terminal.ansiYellow',
115+
'terminal.ansiBlue',
116+
'terminal.ansiMagenta',
117+
'terminal.ansiCyan',
118+
'terminal.ansiWhite'
119+
],
120+
},
121+
}
105122
};
106123

107124
const presentation: IJSONSchema = {
@@ -388,7 +405,6 @@ const taskConfiguration: IJSONSchema = {
388405
default: false
389406
},
390407
presentation: Objects.deepClone(presentation),
391-
color: Objects.deepClone(color),
392408
icon: Objects.deepClone(icon),
393409
options: options,
394410
problemMatcher: {
@@ -467,8 +483,7 @@ taskDescriptionProperties.identifier = Objects.deepClone(identifier);
467483
taskDescriptionProperties.type = Objects.deepClone(taskType);
468484
taskDescriptionProperties.presentation = Objects.deepClone(presentation);
469485
taskDescriptionProperties.terminal = terminal;
470-
taskDescriptionProperties.color = color;
471-
taskDescriptionProperties.icon = icon;
486+
taskDescriptionProperties.icon = Objects.deepClone(icon);
472487
taskDescriptionProperties.group = Objects.deepClone(group);
473488
taskDescriptionProperties.runOptions = Objects.deepClone(runOptions);
474489
taskDescriptionProperties.detail = detail;

src/vs/workbench/contrib/tasks/common/taskConfiguration.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ export interface IConfigurationProperties {
356356
/**
357357
* The icon for this task in the terminal tabs list
358358
*/
359-
icon?: string;
359+
icon?: { id: string; color?: string };
360360

361361
/**
362362
* The icon's color in the terminal tabs list
@@ -1322,7 +1322,6 @@ namespace ConfigurationProperties {
13221322
{ property: 'presentation', type: CommandConfiguration.PresentationOptions },
13231323
{ property: 'problemMatchers' },
13241324
{ property: 'options' },
1325-
{ property: 'color' },
13261325
{ property: 'icon' }
13271326
];
13281327

@@ -1350,12 +1349,7 @@ namespace ConfigurationProperties {
13501349
if (Types.isString(external.identifier)) {
13511350
result.identifier = external.identifier;
13521351
}
1353-
if (Types.isString(external.color)) {
1354-
result.color = external.color;
1355-
}
1356-
if (Types.isString(external.icon)) {
1357-
result.icon = external.icon;
1358-
}
1352+
result.icon = external.icon;
13591353

13601354
if (external.isBackground !== undefined) {
13611355
result.isBackground = !!external.isBackground;
@@ -1641,8 +1635,7 @@ namespace CustomTask {
16411635
{
16421636
name: configuredProps.configurationProperties.name || contributedTask.configurationProperties.name,
16431637
identifier: configuredProps.configurationProperties.identifier || contributedTask.configurationProperties.identifier,
1644-
icon: contributedTask.configurationProperties.icon,
1645-
color: contributedTask.configurationProperties.color
1638+
icon: contributedTask.configurationProperties.icon
16461639
},
16471640

16481641
);

src/vs/workbench/contrib/tasks/common/tasks.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,7 @@ export interface IConfigurationProperties {
548548
/**
549549
* The icon for this task in the terminal tabs list
550550
*/
551-
icon?: string;
552-
553-
/**
554-
* The icon's color in the terminal tabs list
555-
*/
556-
color?: string;
551+
icon?: { id: string; color?: string };
557552
}
558553

559554
export enum RunOnOptions {
@@ -914,13 +909,19 @@ export class ContributedTask extends CommonTask {
914909
*/
915910
command: ICommandConfiguration;
916911

912+
/**
913+
* The icon for the task
914+
*/
915+
icon: { id: string; color?: string } | undefined;
916+
917917
public constructor(id: string, source: IExtensionTaskSource, label: string, type: string | undefined, defines: KeyedTaskIdentifier,
918918
command: ICommandConfiguration, hasDefinedMatchers: boolean, runOptions: IRunOptions,
919919
configurationProperties: IConfigurationProperties) {
920920
super(id, label, type, runOptions, configurationProperties, source);
921921
this.defines = defines;
922922
this.hasDefinedMatchers = hasDefinedMatchers;
923923
this.command = command;
924+
this.icon = configurationProperties.icon;
924925
}
925926

926927
public override clone(): ContributedTask {

0 commit comments

Comments
 (0)