@@ -36,25 +36,31 @@ export class CodeExecutionManager implements ICodeExecutionManager {
3636 }
3737
3838 public registerCommands ( ) {
39- [ Commands . Exec_In_Terminal , Commands . Exec_In_Terminal_Icon ] . forEach ( ( cmd ) => {
40- this . disposableRegistry . push (
41- this . commandManager . registerCommand ( cmd as any , async ( file : Resource ) => {
42- const interpreterService = this . serviceContainer . get < IInterpreterService > ( IInterpreterService ) ;
43- const interpreter = await interpreterService . getActiveInterpreter ( file ) ;
44- if ( ! interpreter ) {
45- this . commandManager . executeCommand ( Commands . TriggerEnvironmentSelection , file ) . then ( noop , noop ) ;
46- return ;
47- }
48- const trigger = cmd === Commands . Exec_In_Terminal ? 'command' : 'icon' ;
49- await this . executeFileInTerminal ( file , trigger )
50- . then ( ( ) => {
51- if ( this . shouldTerminalFocusOnStart ( file ) )
52- this . commandManager . executeCommand ( 'workbench.action.terminal.focus' ) ;
39+ [ Commands . Exec_In_Terminal , Commands . Exec_In_Terminal_Icon , Commands . Exec_In_Separate_Terminal ] . forEach (
40+ ( cmd ) => {
41+ this . disposableRegistry . push (
42+ this . commandManager . registerCommand ( cmd as any , async ( file : Resource ) => {
43+ const interpreterService = this . serviceContainer . get < IInterpreterService > ( IInterpreterService ) ;
44+ const interpreter = await interpreterService . getActiveInterpreter ( file ) ;
45+ if ( ! interpreter ) {
46+ this . commandManager
47+ . executeCommand ( Commands . TriggerEnvironmentSelection , file )
48+ . then ( noop , noop ) ;
49+ return ;
50+ }
51+ const trigger = cmd === Commands . Exec_In_Terminal ? 'command' : 'icon' ;
52+ await this . executeFileInTerminal ( file , trigger , {
53+ newTerminalPerFile : cmd === Commands . Exec_In_Separate_Terminal ,
5354 } )
54- . catch ( ( ex ) => traceError ( 'Failed to execute file in terminal' , ex ) ) ;
55- } ) ,
56- ) ;
57- } ) ;
55+ . then ( ( ) => {
56+ if ( this . shouldTerminalFocusOnStart ( file ) )
57+ this . commandManager . executeCommand ( 'workbench.action.terminal.focus' ) ;
58+ } )
59+ . catch ( ( ex ) => traceError ( 'Failed to execute file in terminal' , ex ) ) ;
60+ } ) ,
61+ ) ;
62+ } ,
63+ ) ;
5864 this . disposableRegistry . push (
5965 this . commandManager . registerCommand ( Commands . Exec_Selection_In_Terminal as any , async ( file : Resource ) => {
6066 const interpreterService = this . serviceContainer . get < IInterpreterService > ( IInterpreterService ) ;
@@ -87,8 +93,16 @@ export class CodeExecutionManager implements ICodeExecutionManager {
8793 ) ,
8894 ) ;
8995 }
90- private async executeFileInTerminal ( file : Resource , trigger : 'command' | 'icon' ) {
91- sendTelemetryEvent ( EventName . EXECUTION_CODE , undefined , { scope : 'file' , trigger } ) ;
96+ private async executeFileInTerminal (
97+ file : Resource ,
98+ trigger : 'command' | 'icon' ,
99+ options ?: { newTerminalPerFile : boolean } ,
100+ ) : Promise < void > {
101+ sendTelemetryEvent ( EventName . EXECUTION_CODE , undefined , {
102+ scope : 'file' ,
103+ trigger,
104+ newTerminalPerFile : options ?. newTerminalPerFile ,
105+ } ) ;
92106 const codeExecutionHelper = this . serviceContainer . get < ICodeExecutionHelper > ( ICodeExecutionHelper ) ;
93107 file = file instanceof Uri ? file : undefined ;
94108 let fileToExecute = file ? file : await codeExecutionHelper . getFileToExecute ( ) ;
@@ -110,7 +124,7 @@ export class CodeExecutionManager implements ICodeExecutionManager {
110124 }
111125
112126 const executionService = this . serviceContainer . get < ICodeExecutionService > ( ICodeExecutionService , 'standard' ) ;
113- await executionService . executeFile ( fileToExecute ) ;
127+ await executionService . executeFile ( fileToExecute , options ) ;
114128 }
115129
116130 @captureTelemetry ( EventName . EXECUTION_CODE , { scope : 'selection' } , false )
0 commit comments