@@ -30,6 +30,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
3030import { IRequestService , asJson } from 'vs/platform/request/common/request' ;
3131import { CancellationToken } from 'vs/base/common/cancellation' ;
3232import { ILogService } from 'vs/platform/log/common/log' ;
33+ import Severity from 'vs/base/common/severity' ;
3334
3435const CREATE_EMPTY_PROFILE_ACTION_ID = 'workbench.profiles.actions.createEmptyProfile' ;
3536const CREATE_EMPTY_PROFILE_ACTION_TITLE = {
@@ -500,14 +501,19 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
500501
501502 const quickPick = this . quickInputService . createQuickPick ( ) ;
502503 quickPick . title = title ;
503- quickPick . hideInput = true ;
504+ quickPick . placeholder = localize ( 'name placeholder' , "Name the new profile" ) ;
504505 quickPick . canSelectMany = true ;
506+ quickPick . matchOnDescription = false ;
507+ quickPick . matchOnDetail = false ;
508+ quickPick . matchOnLabel = false ;
509+ quickPick . sortByLabel = false ;
510+ quickPick . hideCountBadge = true ;
505511 quickPick . ok = false ;
506512 quickPick . customButton = true ;
507513 quickPick . hideCheckAll = true ;
508514 quickPick . ignoreFocusOut = true ;
509515 quickPick . customLabel = localize ( 'create' , "Create Profile" ) ;
510- quickPick . description = localize ( 'customise the profile' , "Choose what you want to configure in the profile. Unselected items are shared from the default profile." ) ;
516+ quickPick . description = localize ( 'customise the profile' , "Choose what to configure in the profile. Unselected items are shared from the default profile." ) ;
511517 quickPick . items = resources ;
512518 quickPick . selectedItems = resources . filter ( item => item . picked ) ;
513519
@@ -518,12 +524,29 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
518524 }
519525 } ) ) ;
520526
521- let result : ReadonlyArray < IQuickPickItem > | undefined ;
527+ disposables . add ( quickPick . onDidChangeValue ( value => {
528+ if ( this . userDataProfilesService . profiles . some ( p => p . name === value ) ) {
529+ quickPick . validationMessage = localize ( 'profileExists' , "Profile with name {0} already exists." , value ) ;
530+ quickPick . severity = Severity . Error ;
531+ } else {
532+ quickPick . severity = Severity . Ignore ;
533+ quickPick . validationMessage = undefined ;
534+ }
535+ } ) ) ;
536+
537+ let result : { name : string ; items : ReadonlyArray < IQuickPickItem > } | undefined ;
522538 disposables . add ( quickPick . onDidCustom ( async ( ) => {
539+ if ( ! quickPick . value ) {
540+ quickPick . validationMessage = localize ( 'name required' , "Provide a name for the new profile" ) ;
541+ quickPick . severity = Severity . Error ;
542+ return ;
543+ }
523544 if ( resources . some ( resource => quickPick . selectedItems . includes ( resource ) ) ) {
524- result = quickPick . selectedItems ;
545+ result = { name : quickPick . value , items : quickPick . selectedItems } ;
525546 quickPick . hide ( ) ;
526547 }
548+ quickPick . severity = Severity . Ignore ;
549+ quickPick . validationMessage = undefined ;
527550 } ) ) ;
528551 quickPick . show ( ) ;
529552
@@ -538,18 +561,14 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
538561 return ;
539562 }
540563
541- const name = await this . getNameForProfile ( title ) ;
542- if ( ! name ) {
543- return ;
544- }
545-
564+ const { name, items } = result ;
546565 try {
547- const useDefaultFlags : UseDefaultProfileFlags | undefined = result . length !== resources . length ? {
548- settings : ! result . includes ( settings ) ,
549- keybindings : ! result . includes ( keybindings ) ,
550- snippets : ! result . includes ( snippets ) ,
551- tasks : ! result . includes ( tasks ) ,
552- extensions : ! result . includes ( extensions )
566+ const useDefaultFlags : UseDefaultProfileFlags | undefined = items . length !== resources . length ? {
567+ settings : ! items . includes ( settings ) ,
568+ keybindings : ! items . includes ( keybindings ) ,
569+ snippets : ! items . includes ( snippets ) ,
570+ tasks : ! items . includes ( tasks ) ,
571+ extensions : ! items . includes ( extensions )
553572 } : undefined ;
554573 await this . userDataProfileManagementService . createAndEnterProfile ( name , { useDefaultFlags } ) ;
555574 } catch ( error ) {
0 commit comments