@@ -83,6 +83,7 @@ import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cance
8383const QUICKOPEN_HISTORY_LIMIT_CONFIG = 'task.quickOpen.history' ;
8484const QUICKOPEN_DETAIL_CONFIG = 'task.quickOpen.detail' ;
8585const PROBLEM_MATCHER_NEVER_CONFIG = 'task.problemMatchers.neverPrompt' ;
86+ const QUICKOPEN_SKIP_CONFIG = 'task.quickOpen.skip' ;
8687
8788export namespace ConfigureTaskAction {
8889 export const ID = 'workbench.action.tasks.configureTaskRunner' ;
@@ -2022,22 +2023,27 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
20222023 }
20232024
20242025 private showQuickPick ( tasks : Promise < Task [ ] > | Task [ ] , placeHolder : string , defaultEntry ?: TaskQuickPickEntry , group : boolean = false , sort : boolean = false , selectedEntry ?: TaskQuickPickEntry , additionalEntries ?: TaskQuickPickEntry [ ] ) : Promise < TaskQuickPickEntry | undefined | null > {
2026+ const tokenSource = new CancellationTokenSource ( ) ;
2027+ const cancellationToken : CancellationToken = tokenSource . token ;
20252028 let _createEntries = ( ) : Promise < QuickPickInput < TaskQuickPickEntry > [ ] > => {
20262029 if ( Array . isArray ( tasks ) ) {
20272030 return Promise . resolve ( this . createTaskQuickPickEntries ( tasks , group , sort , selectedEntry ) ) ;
20282031 } else {
20292032 return tasks . then ( ( tasks ) => this . createTaskQuickPickEntries ( tasks , group , sort , selectedEntry ) ) ;
20302033 }
20312034 } ;
2032- return this . quickInputService . pick ( _createEntries ( ) . then ( ( entries ) => {
2033- if ( ( entries . length === 0 ) && defaultEntry ) {
2035+ const pickEntries = _createEntries ( ) . then ( ( entries ) => {
2036+ if ( ( entries . length === 1 ) && this . configurationService . getValue < boolean > ( QUICKOPEN_SKIP_CONFIG ) ) {
2037+ tokenSource . cancel ( ) ;
2038+ } else if ( ( entries . length === 0 ) && defaultEntry ) {
20342039 entries . push ( defaultEntry ) ;
20352040 } else if ( entries . length > 1 && additionalEntries && additionalEntries . length > 0 ) {
20362041 entries . push ( { type : 'separator' , label : '' } ) ;
20372042 entries . push ( additionalEntries [ 0 ] ) ;
20382043 }
20392044 return entries ;
2040- } ) , {
2045+ } ) ;
2046+ return this . quickInputService . pick ( pickEntries , {
20412047 placeHolder,
20422048 matchOnDescription : true ,
20432049 onDidTriggerItemButton : context => {
@@ -2049,6 +2055,18 @@ export abstract class AbstractTaskService extends Disposable implements ITaskSer
20492055 this . openConfig ( task ) ;
20502056 }
20512057 }
2058+ } , cancellationToken ) . then ( async ( selection ) => {
2059+ if ( cancellationToken . isCancellationRequested ) {
2060+ // canceled when there's only one task
2061+ const task = ( await pickEntries ) [ 0 ] ;
2062+ if ( ( < any > task ) . task ) {
2063+ selection = < TaskQuickPickEntry > task ;
2064+ }
2065+ }
2066+ if ( ! selection ) {
2067+ return ;
2068+ }
2069+ return selection ;
20522070 } ) ;
20532071 }
20542072
0 commit comments