@@ -21,6 +21,8 @@ import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
21
21
import { IDialogService } from 'vs/platform/dialogs/common/dialogs' ;
22
22
import { getColorClass , getColorStyleElement } from 'vs/workbench/contrib/terminal/browser/terminalIcon' ;
23
23
import { TaskQuickPickEntryType } from 'vs/workbench/contrib/tasks/browser/abstractTaskService' ;
24
+ import { showWithPinnedItems } from 'vs/platform/quickinput/browser/quickPickPin' ;
25
+ import { IStorageService } from 'vs/platform/storage/common/storage' ;
24
26
25
27
export const QUICKOPEN_DETAIL_CONFIG = 'task.quickOpen.detail' ;
26
28
export const QUICKOPEN_SKIP_CONFIG = 'task.quickOpen.skip' ;
@@ -42,16 +44,19 @@ const SHOW_ALL: string = nls.localize('taskQuickPick.showAll', "Show All Tasks..
42
44
export const configureTaskIcon = registerIcon ( 'tasks-list-configure' , Codicon . gear , nls . localize ( 'configureTaskIcon' , 'Configuration icon in the tasks selection list.' ) ) ;
43
45
const removeTaskIcon = registerIcon ( 'tasks-remove' , Codicon . close , nls . localize ( 'removeTaskIcon' , 'Icon for remove in the tasks selection list.' ) ) ;
44
46
47
+ const runTaskStorageKey = 'runTaskStorageKey' ;
48
+
45
49
export class TaskQuickPick extends Disposable {
46
50
private _sorter : TaskSorter ;
47
51
private _topLevelEntries : QuickPickInput < ITaskTwoLevelQuickPickEntry > [ ] | undefined ;
48
52
constructor (
49
- private _taskService : ITaskService ,
50
- private _configurationService : IConfigurationService ,
51
- private _quickInputService : IQuickInputService ,
52
- private _notificationService : INotificationService ,
53
- private _themeService : IThemeService ,
54
- private _dialogService : IDialogService ) {
53
+ @ITaskService private _taskService : ITaskService ,
54
+ @IConfigurationService private _configurationService : IConfigurationService ,
55
+ @IQuickInputService private _quickInputService : IQuickInputService ,
56
+ @INotificationService private _notificationService : INotificationService ,
57
+ @IThemeService private _themeService : IThemeService ,
58
+ @IDialogService private _dialogService : IDialogService ,
59
+ @IStorageService private _storageService : IStorageService ) {
55
60
super ( ) ;
56
61
this . _sorter = this . _taskService . createSorter ( ) ;
57
62
}
@@ -225,8 +230,6 @@ export class TaskQuickPick extends Disposable {
225
230
picker . placeholder = placeHolder ;
226
231
picker . matchOnDescription = true ;
227
232
picker . ignoreFocusOut = false ;
228
- picker . show ( ) ;
229
-
230
233
picker . onDidTriggerItemButton ( async ( context ) => {
231
234
const task = context . item . task ;
232
235
if ( context . button . iconClass === ThemeIcon . asClassName ( removeTaskIcon ) ) {
@@ -238,7 +241,7 @@ export class TaskQuickPick extends Disposable {
238
241
if ( indexToRemove >= 0 ) {
239
242
picker . items = [ ...picker . items . slice ( 0 , indexToRemove ) , ...picker . items . slice ( indexToRemove + 1 ) ] ;
240
243
}
241
- } else {
244
+ } else if ( context . button . iconClass === ThemeIcon . asClassName ( configureTaskIcon ) ) {
242
245
this . _quickInputService . cancel ( ) ;
243
246
if ( ContributedTask . is ( task ) ) {
244
247
this . _taskService . customize ( task , undefined , true ) ;
@@ -299,6 +302,7 @@ export class TaskQuickPick extends Disposable {
299
302
300
303
private async _doPickerFirstLevel ( picker : IQuickPick < ITaskTwoLevelQuickPickEntry > , taskQuickPickEntries : QuickPickInput < ITaskTwoLevelQuickPickEntry > [ ] ) : Promise < Task | ConfiguringTask | string | null | undefined > {
301
304
picker . items = taskQuickPickEntries ;
305
+ showWithPinnedItems ( this . _storageService , runTaskStorageKey , picker , true ) ;
302
306
const firstLevelPickerResult = await new Promise < ITaskTwoLevelQuickPickEntry | undefined | null > ( resolve => {
303
307
Event . once ( picker . onDidAccept ) ( async ( ) => {
304
308
resolve ( picker . selectedItems ? picker . selectedItems [ 0 ] : undefined ) ;
@@ -317,7 +321,7 @@ export class TaskQuickPick extends Disposable {
317
321
picker . value = name || '' ;
318
322
picker . items = await this . _getEntriesForProvider ( type ) ;
319
323
}
320
- picker . show ( ) ;
324
+ showWithPinnedItems ( this . _storageService , runTaskStorageKey , picker , true ) ;
321
325
picker . busy = false ;
322
326
const secondLevelPickerResult = await new Promise < ITaskTwoLevelQuickPickEntry | undefined | null > ( resolve => {
323
327
Event . once ( picker . onDidAccept ) ( async ( ) => {
@@ -400,11 +404,4 @@ export class TaskQuickPick extends Disposable {
400
404
}
401
405
return resolvedTask ;
402
406
}
403
-
404
- static async show ( taskService : ITaskService , configurationService : IConfigurationService ,
405
- quickInputService : IQuickInputService , notificationService : INotificationService ,
406
- dialogService : IDialogService , themeService : IThemeService , placeHolder : string , defaultEntry ?: ITaskQuickPickEntry , type ?: string , name ?: string ) {
407
- const taskQuickPick = new TaskQuickPick ( taskService , configurationService , quickInputService , notificationService , themeService , dialogService ) ;
408
- return taskQuickPick . show ( placeHolder , defaultEntry , type , name ) ;
409
- }
410
407
}
0 commit comments