@@ -16,7 +16,7 @@ import { ICreateTerminalOptions, ITerminalLocationOptions, ITerminalService } fr
1616import { TerminalCommandId , TERMINAL_VIEW_ID } from '../common/terminal.js' ;
1717import { TerminalContextKeys , TerminalContextKeyStrings } from '../common/terminalContextKey.js' ;
1818import { 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' ;
2020import { DisposableStore } from '../../../../base/common/lifecycle.js' ;
2121
2222const enum ContextMenuGroup {
@@ -719,39 +719,45 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
719719 className : string ;
720720 dropdownIcon ?: string ;
721721} {
722- let dropdownActions : IAction [ ] = [ ] ;
723- let submenuActions : IAction [ ] = [ ] ;
724- profiles = profiles . filter ( e => ! e . isAutoDetected ) ;
722+ const dropdownActions : IAction [ ] = [ ] ;
723+ const submenuActions : IAction [ ] = [ ] ;
725724 const splitLocation = ( location === TerminalLocation . Editor || ( typeof location === 'object' && 'viewColumn' in location && location . viewColumn === ACTIVE_GROUP ) ) ? { viewColumn : SIDE_GROUP } : { splitActiveTerminal : true } ;
725+
726+ dropdownActions . push ( disposableStore . add ( new Action ( TerminalCommandId . New , terminalStrings . new , undefined , true , ( ) => terminalService . createAndFocusTerminal ( ) ) ) ) ;
727+ dropdownActions . push ( disposableStore . add ( new Action ( TerminalCommandId . NewInNewWindow , terminalStrings . newInNewWindow . short , undefined , true , ( ) => terminalService . createAndFocusTerminal ( {
728+ location : { viewColumn : AUX_WINDOW_GROUP }
729+ } ) ) ) ) ;
730+ dropdownActions . push ( disposableStore . add ( new Action ( TerminalCommandId . Split , terminalStrings . split . value , undefined , true , ( ) => terminalService . createAndFocusTerminal ( {
731+ location : splitLocation
732+ } ) ) ) ) ;
733+ dropdownActions . push ( new Separator ( ) ) ;
734+
735+ profiles = profiles . filter ( e => ! e . isAutoDetected ) ;
726736 for ( const p of profiles ) {
727737 const isDefault = p . profileName === defaultProfileName ;
728738 const options : ICreateTerminalOptions = { config : p , location } ;
729739 const splitOptions : ICreateTerminalOptions = { config : p , location : splitLocation } ;
730740 const sanitizedProfileName = p . profileName . replace ( / [ \n \r \t ] / g, '' ) ;
731741 dropdownActions . push ( disposableStore . add ( new Action ( TerminalCommandId . NewWithProfile , isDefault ? localize ( 'defaultTerminalProfile' , "{0} (Default)" , sanitizedProfileName ) : sanitizedProfileName , undefined , true , async ( ) => {
732- const instance = await terminalService . createTerminal ( options ) ;
733- terminalService . setActiveInstance ( instance ) ;
734- await terminalService . focusActiveInstance ( ) ;
742+ await terminalService . createAndFocusTerminal ( options ) ;
735743 } ) ) ) ;
736744 submenuActions . push ( disposableStore . add ( new Action ( TerminalCommandId . Split , isDefault ? localize ( 'defaultTerminalProfile' , "{0} (Default)" , sanitizedProfileName ) : sanitizedProfileName , undefined , true , async ( ) => {
737- const instance = await terminalService . createTerminal ( splitOptions ) ;
738- terminalService . setActiveInstance ( instance ) ;
739- await terminalService . focusActiveInstance ( ) ;
745+ await terminalService . createAndFocusTerminal ( splitOptions ) ;
740746 } ) ) ) ;
741747 }
742748
743749 for ( const contributed of contributedProfiles ) {
744750 const isDefault = contributed . title === defaultProfileName ;
745751 const title = isDefault ? localize ( 'defaultTerminalProfile' , "{0} (Default)" , contributed . title . replace ( / [ \n \r \t ] / g, '' ) ) : contributed . title . replace ( / [ \n \r \t ] / g, '' ) ;
746- dropdownActions . push ( disposableStore . add ( new Action ( 'contributed' , title , undefined , true , ( ) => terminalService . createTerminal ( {
752+ dropdownActions . push ( disposableStore . add ( new Action ( 'contributed' , title , undefined , true , ( ) => terminalService . createAndFocusTerminal ( {
747753 config : {
748754 extensionIdentifier : contributed . extensionIdentifier ,
749755 id : contributed . id ,
750756 title
751757 } ,
752758 location
753759 } ) ) ) ) ;
754- submenuActions . push ( disposableStore . add ( new Action ( 'contributed-split' , title , undefined , true , ( ) => terminalService . createTerminal ( {
760+ submenuActions . push ( disposableStore . add ( new Action ( 'contributed-split' , title , undefined , true , ( ) => terminalService . createAndFocusTerminal ( {
755761 config : {
756762 extensionIdentifier : contributed . extensionIdentifier ,
757763 id : contributed . id ,
@@ -761,25 +767,13 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
761767 } ) ) ) ) ;
762768 }
763769
764- const defaultProfileAction = dropdownActions . find ( d => d . label . endsWith ( '(Default)' ) ) ;
765- if ( defaultProfileAction ) {
766- dropdownActions = dropdownActions . filter ( d => d !== defaultProfileAction ) . sort ( ( a , b ) => a . label . localeCompare ( b . label ) ) ;
767- dropdownActions . unshift ( defaultProfileAction ) ;
768- }
769-
770770 if ( dropdownActions . length > 0 ) {
771- dropdownActions . push ( new SubmenuAction ( 'split.profile' , localize ( 'splitTerminal ' , 'Split Terminal' ) , submenuActions ) ) ;
771+ dropdownActions . push ( new SubmenuAction ( 'split.profile' , localize ( 'split.profile ' , 'Split Terminal with Profile ' ) , submenuActions ) ) ;
772772 dropdownActions . push ( new Separator ( ) ) ;
773773 }
774774 const actions = dropdownMenu . getActions ( ) ;
775775 dropdownActions . push ( ...Separator . join ( ...actions . map ( a => a [ 1 ] ) ) ) ;
776776
777- const defaultSubmenuProfileAction = submenuActions . find ( d => d . label . endsWith ( '(Default)' ) ) ;
778- if ( defaultSubmenuProfileAction ) {
779- submenuActions = submenuActions . filter ( d => d !== defaultSubmenuProfileAction ) . sort ( ( a , b ) => a . label . localeCompare ( b . label ) ) ;
780- submenuActions . unshift ( defaultSubmenuProfileAction ) ;
781- }
782-
783777 const dropdownAction = disposableStore . add ( new Action ( 'refresh profiles' , localize ( 'launchProfile' , 'Launch Profile...' ) , 'codicon-chevron-down' , true ) ) ;
784778 return { dropdownAction, dropdownMenuActions : dropdownActions , className : `terminal-tab-actions-${ terminalService . resolveLocation ( location ) } ` } ;
785779}
0 commit comments