@@ -30,6 +30,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
30
30
import { IRequestService , asJson } from 'vs/platform/request/common/request' ;
31
31
import { CancellationToken } from 'vs/base/common/cancellation' ;
32
32
import { ILogService } from 'vs/platform/log/common/log' ;
33
+ import Severity from 'vs/base/common/severity' ;
33
34
34
35
const CREATE_EMPTY_PROFILE_ACTION_ID = 'workbench.profiles.actions.createEmptyProfile' ;
35
36
const CREATE_EMPTY_PROFILE_ACTION_TITLE = {
@@ -500,14 +501,19 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
500
501
501
502
const quickPick = this . quickInputService . createQuickPick ( ) ;
502
503
quickPick . title = title ;
503
- quickPick . hideInput = true ;
504
+ quickPick . placeholder = localize ( 'name placeholder' , "Name the new profile" ) ;
504
505
quickPick . canSelectMany = true ;
506
+ quickPick . matchOnDescription = false ;
507
+ quickPick . matchOnDetail = false ;
508
+ quickPick . matchOnLabel = false ;
509
+ quickPick . sortByLabel = false ;
510
+ quickPick . hideCountBadge = true ;
505
511
quickPick . ok = false ;
506
512
quickPick . customButton = true ;
507
513
quickPick . hideCheckAll = true ;
508
514
quickPick . ignoreFocusOut = true ;
509
515
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." ) ;
511
517
quickPick . items = resources ;
512
518
quickPick . selectedItems = resources . filter ( item => item . picked ) ;
513
519
@@ -518,12 +524,29 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
518
524
}
519
525
} ) ) ;
520
526
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 ;
522
538
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
+ }
523
544
if ( resources . some ( resource => quickPick . selectedItems . includes ( resource ) ) ) {
524
- result = quickPick . selectedItems ;
545
+ result = { name : quickPick . value , items : quickPick . selectedItems } ;
525
546
quickPick . hide ( ) ;
526
547
}
548
+ quickPick . severity = Severity . Ignore ;
549
+ quickPick . validationMessage = undefined ;
527
550
} ) ) ;
528
551
quickPick . show ( ) ;
529
552
@@ -538,18 +561,14 @@ export class UserDataProfilesWorkbenchContribution extends Disposable implements
538
561
return ;
539
562
}
540
563
541
- const name = await this . getNameForProfile ( title ) ;
542
- if ( ! name ) {
543
- return ;
544
- }
545
-
564
+ const { name, items } = result ;
546
565
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 )
553
572
} : undefined ;
554
573
await this . userDataProfileManagementService . createAndEnterProfile ( name , { useDefaultFlags } ) ;
555
574
} catch ( error ) {
0 commit comments