@@ -9,17 +9,17 @@ import { Task, ContributedTask, CustomTask, ConfiguringTask, TaskSorter, KeyedTa
9
9
import { IWorkspace , IWorkspaceFolder } from 'vs/platform/workspace/common/workspace' ;
10
10
import * as Types from 'vs/base/common/types' ;
11
11
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' ;
13
13
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
14
14
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' ;
16
16
import { Event } from 'vs/base/common/event' ;
17
17
import { INotificationService , Severity } from 'vs/platform/notification/common/notification' ;
18
18
import { Codicon } from 'vs/base/common/codicons' ;
19
19
import { IThemeService , ThemeIcon } from 'vs/platform/theme/common/themeService' ;
20
20
import { registerIcon } from 'vs/platform/theme/common/iconRegistry' ;
21
21
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' ;
23
23
import { TaskQuickPickEntryType } from 'vs/workbench/contrib/tasks/browser/abstractTaskService' ;
24
24
25
25
export const QUICKOPEN_DETAIL_CONFIG = 'task.quickOpen.detail' ;
@@ -78,25 +78,25 @@ export class TaskQuickPick extends Disposable {
78
78
}
79
79
80
80
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 } ` ;
82
86
}
83
87
84
88
public static applyColorStyles ( task : Task | ConfiguringTask , entry : TaskQuickPickEntryType | ITaskTwoLevelQuickPickEntry , themeService : IThemeService ) : void {
85
- if ( task . configurationProperties . color ) {
89
+ if ( task . configurationProperties . icon ?. color ) {
86
90
const colorTheme = themeService . getColorTheme ( ) ;
87
91
const styleElement = getColorStyleElement ( colorTheme ) ;
88
- entry . iconClasses = [ getColorClass ( task . configurationProperties . color ) ] ;
92
+ entry . iconClasses = [ getColorClass ( task . configurationProperties . icon . color ) ] ;
89
93
document . body . appendChild ( styleElement ) ;
90
94
}
91
95
}
92
96
93
97
private _createTaskEntry ( task : Task | ConfiguringTask , extraButtons : IQuickInputButton [ ] = [ ] ) : ITaskTwoLevelQuickPickEntry {
94
- const customizeIconButton = { iconClass : ThemeIcon . asClassName ( Codicon . pencil ) , tooltip : nls . localize ( 'setIconAndColor' , "Choose color and icon" ) } ;
95
98
const entry : ITaskTwoLevelQuickPickEntry = { label : this . _guessTaskLabel ( task ) , description : this . _taskService . getTaskDescription ( task ) , task, detail : this . _showDetail ( ) ? task . configurationProperties . detail : undefined } ;
96
99
entry . buttons = [ ] ;
97
- if ( CustomTask . is ( task ) ) {
98
- entry . buttons . push ( customizeIconButton ) ;
99
- }
100
100
entry . buttons . push ( { iconClass : ThemeIcon . asClassName ( configureTaskIcon ) , tooltip : nls . localize ( 'configureTask' , "Configure Task" ) } ) ;
101
101
entry . buttons . push ( ...extraButtons ) ;
102
102
TaskQuickPick . applyColorStyles ( task , entry , this . _themeService ) ;
@@ -234,9 +234,6 @@ export class TaskQuickPick extends Disposable {
234
234
if ( indexToRemove >= 0 ) {
235
235
picker . items = [ ...picker . items . slice ( 0 , indexToRemove ) , ...picker . items . slice ( indexToRemove + 1 ) ] ;
236
236
}
237
- } else if ( context . button . iconClass = ThemeIcon . asClassName ( Codicon . pencil ) ) {
238
- await this . _setColor ( task ) ;
239
- await this . _setIcon ( task ) ;
240
237
} else {
241
238
this . _quickInputService . cancel ( ) ;
242
239
if ( ContributedTask . is ( task ) ) {
@@ -291,72 +288,6 @@ export class TaskQuickPick extends Disposable {
291
288
return ;
292
289
}
293
290
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
- }
360
291
361
292
362
293
private async _doPickerFirstLevel ( picker : IQuickPick < ITaskTwoLevelQuickPickEntry > , taskQuickPickEntries : QuickPickInput < ITaskTwoLevelQuickPickEntry > [ ] ) : Promise < Task | ConfiguringTask | string | null | undefined > {
0 commit comments