@@ -16,7 +16,7 @@ import { ICreateTerminalOptions, ITerminalLocationOptions, ITerminalService } fr
16
16
import { TerminalCommandId , TERMINAL_VIEW_ID } from '../common/terminal.js' ;
17
17
import { TerminalContextKeys , TerminalContextKeyStrings } from '../common/terminalContextKey.js' ;
18
18
import { terminalStrings } from '../common/terminalStrings.js' ;
19
- import { ACTIVE_GROUP , SIDE_GROUP } from '../../../services/editor/common/editorService.js' ;
19
+ import { ACTIVE_GROUP , AUX_WINDOW_GROUP , SIDE_GROUP } from '../../../services/editor/common/editorService.js' ;
20
20
import { DisposableStore } from '../../../../base/common/lifecycle.js' ;
21
21
22
22
const enum ContextMenuGroup {
@@ -686,39 +686,45 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
686
686
className : string ;
687
687
dropdownIcon ?: string ;
688
688
} {
689
- let dropdownActions : IAction [ ] = [ ] ;
690
- let submenuActions : IAction [ ] = [ ] ;
691
- profiles = profiles . filter ( e => ! e . isAutoDetected ) ;
689
+ const dropdownActions : IAction [ ] = [ ] ;
690
+ const submenuActions : IAction [ ] = [ ] ;
692
691
const splitLocation = ( location === TerminalLocation . Editor || ( typeof location === 'object' && 'viewColumn' in location && location . viewColumn === ACTIVE_GROUP ) ) ? { viewColumn : SIDE_GROUP } : { splitActiveTerminal : true } ;
692
+
693
+ dropdownActions . push ( disposableStore . add ( new Action ( TerminalCommandId . New , terminalStrings . newInView , undefined , true , ( ) => terminalService . createAndFocusTerminal ( ) ) ) ) ;
694
+ dropdownActions . push ( disposableStore . add ( new Action ( TerminalCommandId . NewInNewWindow , terminalStrings . newInNewWindow . short , undefined , true , ( ) => terminalService . createAndFocusTerminal ( {
695
+ location : { viewColumn : AUX_WINDOW_GROUP }
696
+ } ) ) ) ) ;
697
+ dropdownActions . push ( disposableStore . add ( new Action ( TerminalCommandId . Split , terminalStrings . split . value , undefined , true , ( ) => terminalService . createAndFocusTerminal ( {
698
+ location : splitLocation
699
+ } ) ) ) ) ;
700
+ dropdownActions . push ( new Separator ( ) ) ;
701
+
702
+ profiles = profiles . filter ( e => ! e . isAutoDetected ) ;
693
703
for ( const p of profiles ) {
694
704
const isDefault = p . profileName === defaultProfileName ;
695
705
const options : ICreateTerminalOptions = { config : p , location } ;
696
706
const splitOptions : ICreateTerminalOptions = { config : p , location : splitLocation } ;
697
707
const sanitizedProfileName = p . profileName . replace ( / [ \n \r \t ] / g, '' ) ;
698
708
dropdownActions . push ( disposableStore . add ( new Action ( TerminalCommandId . NewWithProfile , isDefault ? localize ( 'defaultTerminalProfile' , "{0} (Default)" , sanitizedProfileName ) : sanitizedProfileName , undefined , true , async ( ) => {
699
- const instance = await terminalService . createTerminal ( options ) ;
700
- terminalService . setActiveInstance ( instance ) ;
701
- await terminalService . focusActiveInstance ( ) ;
709
+ await terminalService . createAndFocusTerminal ( options ) ;
702
710
} ) ) ) ;
703
711
submenuActions . push ( disposableStore . add ( new Action ( TerminalCommandId . Split , isDefault ? localize ( 'defaultTerminalProfile' , "{0} (Default)" , sanitizedProfileName ) : sanitizedProfileName , undefined , true , async ( ) => {
704
- const instance = await terminalService . createTerminal ( splitOptions ) ;
705
- terminalService . setActiveInstance ( instance ) ;
706
- await terminalService . focusActiveInstance ( ) ;
712
+ await terminalService . createAndFocusTerminal ( splitOptions ) ;
707
713
} ) ) ) ;
708
714
}
709
715
710
716
for ( const contributed of contributedProfiles ) {
711
717
const isDefault = contributed . title === defaultProfileName ;
712
718
const title = isDefault ? localize ( 'defaultTerminalProfile' , "{0} (Default)" , contributed . title . replace ( / [ \n \r \t ] / g, '' ) ) : contributed . title . replace ( / [ \n \r \t ] / g, '' ) ;
713
- dropdownActions . push ( disposableStore . add ( new Action ( 'contributed' , title , undefined , true , ( ) => terminalService . createTerminal ( {
719
+ dropdownActions . push ( disposableStore . add ( new Action ( 'contributed' , title , undefined , true , ( ) => terminalService . createAndFocusTerminal ( {
714
720
config : {
715
721
extensionIdentifier : contributed . extensionIdentifier ,
716
722
id : contributed . id ,
717
723
title
718
724
} ,
719
725
location
720
726
} ) ) ) ) ;
721
- submenuActions . push ( disposableStore . add ( new Action ( 'contributed-split' , title , undefined , true , ( ) => terminalService . createTerminal ( {
727
+ submenuActions . push ( disposableStore . add ( new Action ( 'contributed-split' , title , undefined , true , ( ) => terminalService . createAndFocusTerminal ( {
722
728
config : {
723
729
extensionIdentifier : contributed . extensionIdentifier ,
724
730
id : contributed . id ,
@@ -728,25 +734,13 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
728
734
} ) ) ) ) ;
729
735
}
730
736
731
- const defaultProfileAction = dropdownActions . find ( d => d . label . endsWith ( '(Default)' ) ) ;
732
- if ( defaultProfileAction ) {
733
- dropdownActions = dropdownActions . filter ( d => d !== defaultProfileAction ) . sort ( ( a , b ) => a . label . localeCompare ( b . label ) ) ;
734
- dropdownActions . unshift ( defaultProfileAction ) ;
735
- }
736
-
737
737
if ( dropdownActions . length > 0 ) {
738
- dropdownActions . push ( new SubmenuAction ( 'split.profile' , localize ( 'splitTerminal ' , 'Split Terminal' ) , submenuActions ) ) ;
738
+ dropdownActions . push ( new SubmenuAction ( 'split.profile' , localize ( 'split.profile ' , 'Split Terminal with Profile ' ) , submenuActions ) ) ;
739
739
dropdownActions . push ( new Separator ( ) ) ;
740
740
}
741
741
const actions = dropdownMenu . getActions ( ) ;
742
742
dropdownActions . push ( ...Separator . join ( ...actions . map ( a => a [ 1 ] ) ) ) ;
743
743
744
- const defaultSubmenuProfileAction = submenuActions . find ( d => d . label . endsWith ( '(Default)' ) ) ;
745
- if ( defaultSubmenuProfileAction ) {
746
- submenuActions = submenuActions . filter ( d => d !== defaultSubmenuProfileAction ) . sort ( ( a , b ) => a . label . localeCompare ( b . label ) ) ;
747
- submenuActions . unshift ( defaultSubmenuProfileAction ) ;
748
- }
749
-
750
744
const dropdownAction = disposableStore . add ( new Action ( 'refresh profiles' , localize ( 'launchProfile' , 'Launch Profile...' ) , 'codicon-chevron-down' , true ) ) ;
751
745
return { dropdownAction, dropdownMenuActions : dropdownActions , className : `terminal-tab-actions-${ terminalService . resolveLocation ( location ) } ` } ;
752
746
}
0 commit comments