@@ -21,6 +21,8 @@ import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
2121import { IDialogService } from 'vs/platform/dialogs/common/dialogs' ;
2222import { getColorClass , getColorStyleElement } from 'vs/workbench/contrib/terminal/browser/terminalIcon' ;
2323import { 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' ;
2426
2527export const QUICKOPEN_DETAIL_CONFIG = 'task.quickOpen.detail' ;
2628export const QUICKOPEN_SKIP_CONFIG = 'task.quickOpen.skip' ;
@@ -42,16 +44,19 @@ const SHOW_ALL: string = nls.localize('taskQuickPick.showAll', "Show All Tasks..
4244export const configureTaskIcon = registerIcon ( 'tasks-list-configure' , Codicon . gear , nls . localize ( 'configureTaskIcon' , 'Configuration icon in the tasks selection list.' ) ) ;
4345const removeTaskIcon = registerIcon ( 'tasks-remove' , Codicon . close , nls . localize ( 'removeTaskIcon' , 'Icon for remove in the tasks selection list.' ) ) ;
4446
47+ const runTaskStorageKey = 'runTaskStorageKey' ;
48+
4549export class TaskQuickPick extends Disposable {
4650 private _sorter : TaskSorter ;
4751 private _topLevelEntries : QuickPickInput < ITaskTwoLevelQuickPickEntry > [ ] | undefined ;
4852 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 ) {
5560 super ( ) ;
5661 this . _sorter = this . _taskService . createSorter ( ) ;
5762 }
@@ -225,8 +230,6 @@ export class TaskQuickPick extends Disposable {
225230 picker . placeholder = placeHolder ;
226231 picker . matchOnDescription = true ;
227232 picker . ignoreFocusOut = false ;
228- picker . show ( ) ;
229-
230233 picker . onDidTriggerItemButton ( async ( context ) => {
231234 const task = context . item . task ;
232235 if ( context . button . iconClass === ThemeIcon . asClassName ( removeTaskIcon ) ) {
@@ -238,7 +241,7 @@ export class TaskQuickPick extends Disposable {
238241 if ( indexToRemove >= 0 ) {
239242 picker . items = [ ...picker . items . slice ( 0 , indexToRemove ) , ...picker . items . slice ( indexToRemove + 1 ) ] ;
240243 }
241- } else {
244+ } else if ( context . button . iconClass === ThemeIcon . asClassName ( configureTaskIcon ) ) {
242245 this . _quickInputService . cancel ( ) ;
243246 if ( ContributedTask . is ( task ) ) {
244247 this . _taskService . customize ( task , undefined , true ) ;
@@ -299,6 +302,7 @@ export class TaskQuickPick extends Disposable {
299302
300303 private async _doPickerFirstLevel ( picker : IQuickPick < ITaskTwoLevelQuickPickEntry > , taskQuickPickEntries : QuickPickInput < ITaskTwoLevelQuickPickEntry > [ ] ) : Promise < Task | ConfiguringTask | string | null | undefined > {
301304 picker . items = taskQuickPickEntries ;
305+ showWithPinnedItems ( this . _storageService , runTaskStorageKey , picker , true ) ;
302306 const firstLevelPickerResult = await new Promise < ITaskTwoLevelQuickPickEntry | undefined | null > ( resolve => {
303307 Event . once ( picker . onDidAccept ) ( async ( ) => {
304308 resolve ( picker . selectedItems ? picker . selectedItems [ 0 ] : undefined ) ;
@@ -317,7 +321,7 @@ export class TaskQuickPick extends Disposable {
317321 picker . value = name || '' ;
318322 picker . items = await this . _getEntriesForProvider ( type ) ;
319323 }
320- picker . show ( ) ;
324+ showWithPinnedItems ( this . _storageService , runTaskStorageKey , picker , true ) ;
321325 picker . busy = false ;
322326 const secondLevelPickerResult = await new Promise < ITaskTwoLevelQuickPickEntry | undefined | null > ( resolve => {
323327 Event . once ( picker . onDidAccept ) ( async ( ) => {
@@ -400,11 +404,4 @@ export class TaskQuickPick extends Disposable {
400404 }
401405 return resolvedTask ;
402406 }
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- }
410407}
0 commit comments