@@ -25,6 +25,8 @@ import { TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR, TERMINAL_COMMAND_
25
25
import { Color } from 'vs/base/common/color' ;
26
26
import { IOpenerService } from 'vs/platform/opener/common/opener' ;
27
27
import { IGenericMarkProperties } from 'vs/platform/terminal/common/terminalProcess' ;
28
+ import { IQuickInputService , IQuickPickItem } from 'vs/platform/quickinput/common/quickInput' ;
29
+ import { Codicon } from 'vs/base/common/codicons' ;
28
30
29
31
const enum DecorationSelector {
30
32
CommandDecoration = 'terminal-command-decoration' ,
@@ -65,7 +67,8 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
65
67
@IHoverService private readonly _hoverService : IHoverService ,
66
68
@IConfigurationService private readonly _configurationService : IConfigurationService ,
67
69
@IThemeService private readonly _themeService : IThemeService ,
68
- @IOpenerService private readonly _openerService : IOpenerService
70
+ @IOpenerService private readonly _openerService : IOpenerService ,
71
+ @IQuickInputService private readonly _quickInputService : IQuickInputService
69
72
) {
70
73
super ( ) ;
71
74
this . _register ( toDisposable ( ( ) => this . _dispose ( ) ) ) ;
@@ -431,13 +434,102 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
431
434
if ( actions . length > 0 ) {
432
435
actions . push ( new Separator ( ) ) ;
433
436
}
434
- const label = localize ( "terminal.learnShellIntegration " , 'Learn About Shell Integration ' ) ;
437
+ const labelConfigure = localize ( "terminal.configureCommandDecorations " , 'Configure Command Decorations ' ) ;
435
438
actions . push ( {
436
- class : undefined , tooltip : label , dispose : ( ) => { } , id : 'terminal.learnShellIntegration' , label, enabled : true ,
439
+ class : undefined , tooltip : labelConfigure , dispose : ( ) => { } , id : 'terminal.configureCommandDecorations' , label : labelConfigure , enabled : true ,
440
+ run : ( ) => this . _showConfigureCommandDecorationsQuickPick ( )
441
+ } ) ;
442
+ const labelAbout = localize ( "terminal.learnShellIntegration" , 'Learn About Shell Integration' ) ;
443
+ actions . push ( {
444
+ class : undefined , tooltip : labelAbout , dispose : ( ) => { } , id : 'terminal.learnShellIntegration' , label : labelAbout , enabled : true ,
437
445
run : ( ) => this . _openerService . open ( 'https://code.visualstudio.com/docs/editor/integrated-terminal#_shell-integration' )
438
446
} ) ;
439
447
return actions ;
440
448
}
449
+
450
+ private async _showConfigureCommandDecorationsQuickPick ( ) {
451
+ const quickPick = this . _quickInputService . createQuickPick ( ) ;
452
+ quickPick . items = [
453
+ { id : 'a' , label : localize ( 'changeDefaultIcon' , 'Change default icon' ) } ,
454
+ { id : 'b' , label : localize ( 'changeSuccessIcon' , 'Change success icon' ) } ,
455
+ { id : 'c' , label : localize ( 'changeErrorIcon' , 'Change error icon' ) } ,
456
+ { type : 'separator' } ,
457
+ { id : 'd' , label : localize ( 'toggleVisibility' , 'Toggle visibility' ) } ,
458
+ ] ;
459
+ quickPick . canSelectMany = false ;
460
+ quickPick . onDidAccept ( async e => {
461
+ quickPick . hide ( ) ;
462
+ const result = quickPick . activeItems [ 0 ] ;
463
+ let iconSetting : string | undefined ;
464
+ switch ( result . id ) {
465
+ case 'a' : iconSetting = TerminalSettingId . ShellIntegrationDecorationIcon ; break ;
466
+ case 'b' : iconSetting = TerminalSettingId . ShellIntegrationDecorationIconSuccess ; break ;
467
+ case 'c' : iconSetting = TerminalSettingId . ShellIntegrationDecorationIconError ; break ;
468
+ case 'd' : this . _showToggleVisibilityQuickPick ( ) ; break ;
469
+ }
470
+ if ( iconSetting ) {
471
+ this . _showChangeIconQuickPick ( iconSetting ) ;
472
+ }
473
+ } ) ;
474
+ quickPick . show ( ) ;
475
+ }
476
+
477
+ private async _showChangeIconQuickPick ( iconSetting : string ) {
478
+ type Item = IQuickPickItem & { icon : Codicon } ;
479
+ const items : Item [ ] = [ ] ;
480
+ for ( const icon of Codicon . getAll ( ) ) {
481
+ items . push ( { label : `$(${ icon . id } )` , description : `${ icon . id } ` , icon } ) ;
482
+ }
483
+ const result = await this . _quickInputService . pick ( items , {
484
+ matchOnDescription : true
485
+ } ) ;
486
+ if ( result ) {
487
+ this . _configurationService . updateValue ( iconSetting , result . icon . id ) ;
488
+ this . _showConfigureCommandDecorationsQuickPick ( ) ;
489
+ }
490
+ }
491
+
492
+ private _showToggleVisibilityQuickPick ( ) {
493
+ const quickPick = this . _quickInputService . createQuickPick ( ) ;
494
+ quickPick . hideInput = true ;
495
+ quickPick . hideCheckAll = true ;
496
+ quickPick . canSelectMany = true ;
497
+ quickPick . title = localize ( 'toggleVisibility' , 'Toggle visibility' ) ;
498
+ const configValue = this . _configurationService . getValue ( TerminalSettingId . ShellIntegrationDecorationsEnabled ) ;
499
+ const gutterIcon : IQuickPickItem = {
500
+ label : localize ( 'gutter' , 'Gutter command decorations' ) ,
501
+ picked : configValue !== 'never' && configValue !== 'overviewRuler'
502
+ } ;
503
+ const overviewRulerIcon : IQuickPickItem = {
504
+ label : localize ( 'overviewRuler' , 'Overview ruler command decorations' ) ,
505
+ picked : configValue !== 'never' && configValue !== 'gutter'
506
+ } ;
507
+ quickPick . items = [ gutterIcon , overviewRulerIcon ] ;
508
+ const selectedItems : IQuickPickItem [ ] = [ ] ;
509
+ if ( configValue !== 'never' ) {
510
+ if ( configValue !== 'gutter' ) {
511
+ selectedItems . push ( gutterIcon ) ;
512
+ }
513
+ if ( configValue !== 'overviewRuler' ) {
514
+ selectedItems . push ( overviewRulerIcon ) ;
515
+ }
516
+ }
517
+ quickPick . selectedItems = selectedItems ;
518
+ quickPick . onDidChangeSelection ( async e => {
519
+ let newValue : 'both' | 'gutter' | 'overviewRuler' | 'never' = 'never' ;
520
+ if ( e . includes ( gutterIcon ) ) {
521
+ if ( e . includes ( overviewRulerIcon ) ) {
522
+ newValue = 'both' ;
523
+ } else {
524
+ newValue = 'gutter' ;
525
+ }
526
+ } else if ( e . includes ( overviewRulerIcon ) ) {
527
+ newValue = 'overviewRuler' ;
528
+ }
529
+ await this . _configurationService . updateValue ( TerminalSettingId . ShellIntegrationDecorationsEnabled , newValue ) ;
530
+ } ) ;
531
+ quickPick . show ( ) ;
532
+ }
441
533
}
442
534
let successColor : string | Color | undefined ;
443
535
let errorColor : string | Color | undefined ;
0 commit comments