@@ -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 {
@@ -719,39 +719,45 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
719
719
className : string ;
720
720
dropdownIcon ?: string ;
721
721
} {
722
- let dropdownActions : IAction [ ] = [ ] ;
723
- let submenuActions : IAction [ ] = [ ] ;
724
- profiles = profiles . filter ( e => ! e . isAutoDetected ) ;
722
+ const dropdownActions : IAction [ ] = [ ] ;
723
+ const submenuActions : IAction [ ] = [ ] ;
725
724
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 ) ;
726
736
for ( const p of profiles ) {
727
737
const isDefault = p . profileName === defaultProfileName ;
728
738
const options : ICreateTerminalOptions = { config : p , location } ;
729
739
const splitOptions : ICreateTerminalOptions = { config : p , location : splitLocation } ;
730
740
const sanitizedProfileName = p . profileName . replace ( / [ \n \r \t ] / g, '' ) ;
731
741
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 ) ;
735
743
} ) ) ) ;
736
744
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 ) ;
740
746
} ) ) ) ;
741
747
}
742
748
743
749
for ( const contributed of contributedProfiles ) {
744
750
const isDefault = contributed . title === defaultProfileName ;
745
751
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 ( {
747
753
config : {
748
754
extensionIdentifier : contributed . extensionIdentifier ,
749
755
id : contributed . id ,
750
756
title
751
757
} ,
752
758
location
753
759
} ) ) ) ) ;
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 ( {
755
761
config : {
756
762
extensionIdentifier : contributed . extensionIdentifier ,
757
763
id : contributed . id ,
@@ -761,25 +767,13 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
761
767
} ) ) ) ) ;
762
768
}
763
769
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
-
770
770
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 ) ) ;
772
772
dropdownActions . push ( new Separator ( ) ) ;
773
773
}
774
774
const actions = dropdownMenu . getActions ( ) ;
775
775
dropdownActions . push ( ...Separator . join ( ...actions . map ( a => a [ 1 ] ) ) ) ;
776
776
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
-
783
777
const dropdownAction = disposableStore . add ( new Action ( 'refresh profiles' , localize ( 'launchProfile' , 'Launch Profile...' ) , 'codicon-chevron-down' , true ) ) ;
784
778
return { dropdownAction, dropdownMenuActions : dropdownActions , className : `terminal-tab-actions-${ terminalService . resolveLocation ( location ) } ` } ;
785
779
}
0 commit comments