@@ -36,25 +36,31 @@ export class CodeExecutionManager implements ICodeExecutionManager {
36
36
}
37
37
38
38
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 ,
53
54
} )
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
+ ) ;
58
64
this . disposableRegistry . push (
59
65
this . commandManager . registerCommand ( Commands . Exec_Selection_In_Terminal as any , async ( file : Resource ) => {
60
66
const interpreterService = this . serviceContainer . get < IInterpreterService > ( IInterpreterService ) ;
@@ -87,8 +93,16 @@ export class CodeExecutionManager implements ICodeExecutionManager {
87
93
) ,
88
94
) ;
89
95
}
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
+ } ) ;
92
106
const codeExecutionHelper = this . serviceContainer . get < ICodeExecutionHelper > ( ICodeExecutionHelper ) ;
93
107
file = file instanceof Uri ? file : undefined ;
94
108
let fileToExecute = file ? file : await codeExecutionHelper . getFileToExecute ( ) ;
@@ -110,7 +124,7 @@ export class CodeExecutionManager implements ICodeExecutionManager {
110
124
}
111
125
112
126
const executionService = this . serviceContainer . get < ICodeExecutionService > ( ICodeExecutionService , 'standard' ) ;
113
- await executionService . executeFile ( fileToExecute ) ;
127
+ await executionService . executeFile ( fileToExecute , options ) ;
114
128
}
115
129
116
130
@captureTelemetry ( EventName . EXECUTION_CODE , { scope : 'selection' } , false )
0 commit comments